-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: less support "globalVars" #1465
Conversation
## Walkthrough
此次更改主要引入了对LESS加载器的全局变量支持,增强了样式管理的灵活性和可维护性。通过新增的`globalVars`配置,项目中的LESS样式可以更好地共享和管理变量,促进了一致的主题风格。同时,新增的测试脚本确保样式输出符合预期,提升了项目的可靠性和可测试性。
## Changes
| 文件路径 | 更改摘要 |
|--------------------------------------------------|---------------------------------------------|
| e2e/fixtures.umi/config.less.globalVars/.umirc.ts | 引入LESS加载器的全局变量配置,包含多个样式变量。 |
| e2e/fixtures.umi/config.less.globalVars/expect.js | 添加CSS构建过程的测试,确保样式符合预期。 |
| e2e/fixtures.umi/config.less.globalVars/pages/index.less | 定义多个颜色样式,使用LESS变量进行管理。 |
| e2e/fixtures.umi/config.less.globalVars/pages/a.less | 新增`.normalA`类,使用`@primaryColor`变量。 |
| e2e/fixtures.umi/config.less.globalVars/pages/b.less | 新增`.normalB`类,使用`@primaryColor`变量。 |
| e2e/fixtures.umi/config.less.globalVars/var.less | 新增多个LESS变量,设置颜色值以便于管理。 |
| packages/bundler-mako/index.js | 在配置选项中添加了`globalVars`属性。 |
| packages/mako/src/index.ts | 修改`build`函数,允许传入全局变量。 |
| packages/mako/src/lessLoader/index.ts | 在`LessLoaderOpts`接口中添加了可选的`globalVars`属性。 |
| packages/mako/src/lessLoader/render.ts | 在`render`函数中引入`globalVars`参数。 |
| scripts/mako.js | 在`getMakoConfig`函数中添加`globalVars`属性。 |
## Poem
> 🐇 在小径上跳跃,春风拂面,
> 样式如花,色彩绚烂,
> 新变量来临,管理更轻松,
> LESS的魔法,让我们共舞。
> 一起欢庆,代码更优秀,
> 愿每一行,都如梦美好! ✨ Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (10)
- e2e/fixtures.umi/config.less.globalVars/.umirc.ts (1 hunks)
- e2e/fixtures.umi/config.less.globalVars/expect.js (1 hunks)
- e2e/fixtures.umi/config.less.globalVars/pages/index.less (1 hunks)
- e2e/fixtures.umi/config.less.globalVars/pages/index.tsx (1 hunks)
- e2e/fixtures.umi/config.less.globalVars/var.less (1 hunks)
- packages/bundler-mako/index.js (2 hunks)
- packages/mako/src/index.ts (1 hunks)
- packages/mako/src/lessLoader/index.ts (1 hunks)
- packages/mako/src/lessLoader/render.ts (2 hunks)
- scripts/mako.js (1 hunks)
Files skipped from review due to trivial changes (3)
- e2e/fixtures.umi/config.less.globalVars/pages/index.less
- e2e/fixtures.umi/config.less.globalVars/pages/index.tsx
- e2e/fixtures.umi/config.less.globalVars/var.less
Additional comments not posted (9)
e2e/fixtures.umi/config.less.globalVars/.umirc.ts (1)
1-9
: 配置文件检查这个配置文件看起来是为了支持
globalVars
。代码没有语法错误,配置项也符合预期。e2e/fixtures.umi/config.less.globalVars/expect.js (1)
1-8
: 测试文件检查这个测试文件验证了
globalVars
功能。测试逻辑正确,确保了globalVars
配置被正确应用。packages/mako/src/lessLoader/render.ts (2)
9-9
: 确保全局变量正确传递代码正确地将
globalVars
添加到了解构赋值中,并传递给了 Less 编译器。
29-29
: 确保全局变量正确传递代码正确地将
globalVars
传递给了 Less 编译器。scripts/mako.js (1)
43-44
: 新增的globalVars
属性看起来很好。这个更改增强了配置的灵活性。
请确保在代码库中正确使用了
globalVars
。Verification successful
新增的
globalVars
属性在代码库中已正确使用。以下文件中均有涉及:
scripts/mako.js
packages/mako/src/index.ts
packages/mako/src/lessLoader/render.ts
packages/mako/src/lessLoader/index.ts
packages/bundler-mako/index.js
e2e/fixtures.umi/config.less.globalVars/.umirc.ts
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify usage of `globalVars` in the codebase. # Test: Search for the usage of `globalVars`. Expect: Proper usage in relevant files. rg --type javascript --type typescript --type json 'globalVars'Length of output: 98
Script:
#!/bin/bash # Description: Verify usage of `globalVars` in the codebase. # Test: Search for the usage of `globalVars`. Expect: Proper usage in relevant files. rg --type js --type ts --type json 'globalVars'Length of output: 637
packages/mako/src/lessLoader/index.ts (1)
6-6
: 新增的globalVars
属性看起来很好。这个更改增强了配置的灵活性。
请确保在代码库中正确使用了
globalVars
。Verification successful
globalVars
属性已在代码库中正确使用。以下文件中均有使用
globalVars
:
scripts/mako.js
packages/bundler-mako/index.js
packages/mako/src/index.ts
packages/mako/src/lessLoader/render.ts
e2e/fixtures.umi/config.less.globalVars/.umirc.ts
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify usage of `globalVars` in the codebase. # Test: Search for the usage of `globalVars`. Expect: Proper usage in relevant files. rg --type javascript --type typescript --type json 'globalVars'Length of output: 98
Script:
#!/bin/bash # Description: Verify usage of `globalVars` in the codebase. # Test: Search for the usage of `globalVars`. Expect: Proper usage in relevant files. rg --type js --type ts --type json 'globalVars'Length of output: 637
packages/mako/src/index.ts (1)
93-94
: 新增的globalVars
属性看起来很好。这个更改增强了配置的灵活性。
请确保在代码库中正确使用了
globalVars
。Verification successful
globalVars
属性在代码库中已正确使用。以下是相关文件列表:
scripts/mako.js
packages/bundler-mako/index.js
packages/mako/src/index.ts
e2e/fixtures.umi/config.less.globalVars/.umirc.ts
packages/mako/src/lessLoader/render.ts
packages/mako/src/lessLoader/index.ts
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify usage of `globalVars` in the codebase. # Test: Search for the usage of `globalVars`. Expect: Proper usage in relevant files. rg --type javascript --type typescript --type json 'globalVars'Length of output: 98
Script:
#!/bin/bash # Description: Verify usage of `globalVars` in the codebase. # Test: Search for the usage of `globalVars`. Expect: Proper usage in relevant files. rg --type js --type ts --type json 'globalVars'Length of output: 637
packages/bundler-mako/index.js (2)
367-367
: 新增的globalVars
配置项新增的
globalVars
配置项已正确添加到lessLoader
的支持键列表中。
641-641
: 新增的globalVars
配置项在 LESS 配置中正确添加了
globalVars
配置项。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- e2e/fixtures.umi/config.less.globalVars/expect.js (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- e2e/fixtures.umi/config.less.globalVars/expect.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1、用例没有体现 globalVars 的逻辑
2、文档需要同步调整
globalVars 的逻辑是指? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (8)
- docs/config.md (2 hunks)
- docs/config.zh-CN.md (2 hunks)
- e2e/fixtures.umi/config.less.globalVars/.umirc.ts (1 hunks)
- e2e/fixtures.umi/config.less.globalVars/expect.js (1 hunks)
- e2e/fixtures.umi/config.less.globalVars/pages/a.less (1 hunks)
- e2e/fixtures.umi/config.less.globalVars/pages/b.less (1 hunks)
- e2e/fixtures.umi/config.less.globalVars/pages/index.less (1 hunks)
- e2e/fixtures.umi/config.less.globalVars/var.less (1 hunks)
Files skipped from review due to trivial changes (2)
- e2e/fixtures.umi/config.less.globalVars/pages/a.less
- e2e/fixtures.umi/config.less.globalVars/pages/b.less
Files skipped from review as they are similar to previous changes (2)
- e2e/fixtures.umi/config.less.globalVars/.umirc.ts
- e2e/fixtures.umi/config.less.globalVars/expect.js
Additional comments not posted (11)
e2e/fixtures.umi/config.less.globalVars/var.less (1)
1-3
: 变量声明看起来很好。变量声明符合预期,没有发现问题。
e2e/fixtures.umi/config.less.globalVars/pages/index.less (6)
1-2
: 变量声明看起来很好。变量声明符合预期,没有发现问题。
3-5
: 正常类定义看起来很好。类
.normal
正确使用了@primaryColor
变量。
7-9
: 覆盖类定义看起来很好。类
.override
正确使用了@testOverride
变量。
11-13
: 请验证@globalColorInConfig
变量的定义。类
.inConfig
使用了@globalColorInConfig
变量,但没有在此文件中声明。请确保该变量在其他地方正确定义。
15-17
: 覆盖配置类定义看起来很好。类
.overrideInConfig
正确使用了@overrideInConfig
变量。
19-21
: 请验证@useAtPrefix
变量的定义。类
.useAtPrefix
使用了@useAtPrefix
变量,但没有在此文件中声明。请确保该变量在其他地方正确定义。docs/config.zh-CN.md (2)
378-378
: 文档更新看起来很好。文档正确地添加了
globalVars
配置项。
391-394
: 示例更新看起来很好。示例正确地展示了如何使用
globalVars
配置项。docs/config.md (2)
377-377
: 更改已批准:新增globalVars
属性在 LESS 配置中新增的
globalVars
属性是正确的,并且类型定义也已正确更新。
390-393
: 更改已批准:更新的示例配置示例配置中新增的
globalVars
属性展示了如何使用该属性,示例清晰且准确。
新增了一些测试用例,文档也补充了下。 |
@sorrycc 佬,帮忙再看看吧 |
添加了对
globalVars
的支持,类似于modifyVars
。Summary by CodeRabbit
新功能
测试