Skip to content
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

Merged
merged 8 commits into from
Aug 6, 2024
Merged

Conversation

gin-lsl
Copy link
Contributor

@gin-lsl gin-lsl commented Jul 31, 2024

添加了对 globalVars 的支持,类似于 modifyVars

Summary by CodeRabbit

  • 新功能

    • 引入了 LESS 全局变量的配置,提高了样式的模块化和可维护性。
    • 新增了 CSS 规则,集中管理链接颜色,提升界面视觉一致性。
    • 新增多个 CSS 类,确保样式的一致性和灵活性。
  • 测试

    • 添加了验证 CSS 构建过程的测试工具,确保样式按预期生成。

Copy link
Contributor

coderabbitai bot commented Jul 31, 2024

## 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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits

Files that changed from the base of the PR and between 0ebed32 and bd29614.

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 配置项。

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits

Files that changed from the base of the PR and between bd29614 and 7ab4b9b.

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

Copy link
Member

@sorrycc sorrycc left a comment

Choose a reason for hiding this comment

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

1、用例没有体现 globalVars 的逻辑
2、文档需要同步调整

@gin-lsl
Copy link
Contributor Author

gin-lsl commented Aug 1, 2024

用例没有体现 globalVars 的逻辑

globalVars 的逻辑是指?

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits

Files that changed from the base of the PR and between 7ab4b9b and 69f44be.

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 属性展示了如何使用该属性,示例清晰且准确。

@gin-lsl
Copy link
Contributor Author

gin-lsl commented Aug 2, 2024

新增了一些测试用例,文档也补充了下。

@gin-lsl gin-lsl requested a review from sorrycc August 2, 2024 02:49
@gin-lsl
Copy link
Contributor Author

gin-lsl commented Aug 5, 2024

@sorrycc 佬,帮忙再看看吧

@sorrycc sorrycc merged commit 1b01436 into umijs:master Aug 6, 2024
8 checks passed
@gin-lsl gin-lsl deleted the feat/less-globalVars branch August 23, 2024 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants