Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/sites/sites-react/doc/docs/react/start-react.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ export default defineConfig({
{
libName: '@nutui/nutui-react',
style: (name) => {
// Handling on-demand import of CSS files, choose one of the two methods
return `@nutui/nutui-react/dist/es/packages/${name.toLowerCase()}/style/css`
// Handling on-demand import of SCSS files, choose one of the two methods
return `@nutui/nutui-react/dist/es/packages/${name.toLowerCase()}/style`
},
replaceOldImport: false,
camel2DashComponentName: false,
Expand Down Expand Up @@ -132,7 +135,7 @@ babel config:
'import',
{
libraryName: '@nutui/nutui-react',
style: 'css',
style: 'css', // Here are the CSS files for on-demand import. If you need to import SCSS files, you can set the style to true.
camel2DashComponentName: false,
customName: (name, file) => {
return `@nutui/nutui-react/dist/es/packages/${name.toLowerCase()}`
Expand Down
5 changes: 4 additions & 1 deletion src/sites/sites-react/doc/docs/react/start-react.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ export default defineConfig({
{
libName: '@nutui/nutui-react',
style: (name) => {
// 按需引入 css 文件的处理,两种方式择其一
return `@nutui/nutui-react/dist/es/packages/${name.toLowerCase()}/style/css`
// 按需引入 scss 文件的处理,两种方式择其一
return `@nutui/nutui-react/dist/es/packages/${name.toLowerCase()}/style`
Comment on lines 93 to +97
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

建议优化返回语句逻辑
vite-plugin-imp 的配置示例中,style 函数内存在连续两个 return 语句,其中第一个 return 会使第二个返回永远无法执行。这可能会给用户造成困惑。建议将其中一个返回语句注释掉,并提供详细说明,让用户根据需要选择对应的导入方式。例如,可以保留“按需引入 CSS 文件”的 return,而将“按需引入 SCSS 文件”的返回语句注释掉,并在注释中说明如何切换。

-          style: (name) => {
-            // 按需引入 css 文件的处理,两种方式择其一
-            return `@nutui/nutui-react/dist/es/packages/${name.toLowerCase()}/style/css`
-            // 按需引入 scss 文件的处理,两种方式择其一
-            return `@nutui/nutui-react/dist/es/packages/${name.toLowerCase()}/style`
-          },
+          style: (name) => {
+            // 根据需要选择导入方式,注释掉不使用的方案:
+            // 方案一:按需引入 CSS 文件
+            // return `@nutui/nutui-react/dist/es/packages/${name.toLowerCase()}/style/css`;
+            // 方案二:按需引入 SCSS 文件
+            return `@nutui/nutui-react/dist/es/packages/${name.toLowerCase()}/style`;
+          },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
style: (name) => {
// 按需引入 css 文件的处理,两种方式择其一
return `@nutui/nutui-react/dist/es/packages/${name.toLowerCase()}/style/css`
// 按需引入 scss 文件的处理,两种方式择其一
return `@nutui/nutui-react/dist/es/packages/${name.toLowerCase()}/style`
style: (name) => {
// 根据需要选择导入方式,注释掉不使用的方案:
// 方案一:按需引入 CSS 文件
// return `@nutui/nutui-react/dist/es/packages/${name.toLowerCase()}/style/css`;
// 方案二:按需引入 SCSS 文件
return `@nutui/nutui-react/dist/es/packages/${name.toLowerCase()}/style`;
},

},
replaceOldImport: false,
camel2DashComponentName: false,
Expand Down Expand Up @@ -132,7 +135,7 @@ babel 配置:
'import',
{
libraryName: '@nutui/nutui-react',
style: 'css',
style: 'css', // 这里是按需引入的 css 文件,如果需要引入 scss 文件,可将 style 设置为 true
camel2DashComponentName: false,
customName: (name, file) => {
return `@nutui/nutui-react/dist/es/packages/${name.toLowerCase()}`
Expand Down
2 changes: 2 additions & 0 deletions src/sites/sites-react/doc/docs/react/theme-react.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ We recommend replacing [CSS Vars] (https://developer.mozilla.org/zh-CN/docs/Web/

Create a new 'SCSS' file 'custom_theme.scss' in your local project.

**When customizing themes using SCSS files, you need to set the on-demand import to the SCSS file method. Refer to the description in the automatic on-demand loading configuration in the quick start guide.**

```scss
// Dominant tone
$color-primary: #fa2c19;
Expand Down
2 changes: 2 additions & 0 deletions src/sites/sites-react/doc/docs/react/theme-react.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ NutUI-React 支持灵活的样式定制,满足多种视觉业务和品牌需

在本地项目中新建一个 `SCSS` 文件 `custom_theme.scss` 进行自定义。

**使用 SCSS 文件自定义主题时,需将按需引入设置为 scss 文件的方式,参考快速入手中的自动按需加载配置项中的描述**

```scss
// 主色调
$color-primary: #fa2c19;
Expand Down
2 changes: 1 addition & 1 deletion src/sites/sites-react/doc/docs/taro/start-react.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ plugins: [
'import',
{
libraryName: '@nutui/nutui-react-taro',
style: 'css',
style: 'css', // Here are the CSS files for on-demand import. If you need to import SCSS files, you can set the style to true.
camel2DashComponentName: false,
customName: (name, file) => {
return `@nutui/nutui-react-taro/dist/es/packages/${name.toLowerCase()}`
Expand Down
2 changes: 1 addition & 1 deletion src/sites/sites-react/doc/docs/taro/start-react.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ module.exports = {
'import',
{
libraryName: '@nutui/nutui-react-taro',
style: 'css',
style: 'css', // 这里是按需引入的 css 文件,如果需要引入 scss 文件,可将 style 设置为 true
camel2DashComponentName: false,
customName: (name, file) => {
return `@nutui/nutui-react-taro/dist/es/packages/${name.toLowerCase()}`
Expand Down
4 changes: 3 additions & 1 deletion src/sites/sites-react/doc/docs/taro/theme-react.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ We recommend replacing [CSS Vars] (https://developer.mozilla.org/zh-CN/docs/Web/

Create a new 'SCSS' file 'custom_theme.scss' in your local project.

**When customizing themes using SCSS files, you need to set the on-demand import to the SCSS file method. Refer to the description in the automatic on-demand loading configuration in the quick start guide.**

```scss
// Dominant tone
$color-primary: #fa2c19;
Expand All @@ -32,7 +34,7 @@ $color-primary-end: #fa6419;

#### Step 2: Modify the configuration file of the local project webpack or vite

Modify the ** ass-loader** configuration in the 'vite' or 'webpack' configuration file. The following example
Modify the ** sass-loader** configuration in the 'vite' or 'webpack' configuration file. The following example

#### vite

Expand Down
2 changes: 2 additions & 0 deletions src/sites/sites-react/doc/docs/taro/theme-react.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ NutUI-React 支持灵活的样式定制,满足多种视觉业务和品牌需

在本地项目中新建一个 `SCSS` 文件 `custom_theme.scss` 进行自定义。

**使用 SCSS 文件自定义主题时,需将按需引入设置为 scss 文件的方式,参考快速入手中的自动按需加载配置项中的描述**

```scss
// 主色调
$color-primary: #fa2c19;
Expand Down
Loading