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

fix: #1476 mako support scss #1482

Merged
merged 4 commits into from
Aug 9, 2024
Merged

fix: #1476 mako support scss #1482

merged 4 commits into from
Aug 9, 2024

Conversation

jeasonnow
Copy link
Contributor

@jeasonnow jeasonnow commented Aug 8, 2024

Close #1476

Summary by CodeRabbit

Summary by CodeRabbit

  • 新特性

    • 支持 .scss 文件扩展,增强了样式表解析功能。
    • 新增 SASS 配置文件以便于未来的样式管理。
    • 引入基本的 React 应用程序结构,支持动态内容渲染。
    • 更新样式应用方式,从 CSS 模块改为标准 CSS,简化组件样式引用。
  • 文档

    • 新增 HTML 文件作为应用程序的基础结构。
    • 新增 package.json 文件以配置项目的依赖项。

Copy link
Contributor

coderabbitai bot commented Aug 8, 2024

Walkthrough

此次更改显著扩展了对 SASS 和 SCSS 文件的支持,调整了文件扩展名的处理逻辑。应用移除了对 SASS 和 SCSS 的不支持标记,并增加了对 SCSS 扩展名的识别。这一变化使得该应用程序能够更灵活地处理不同类型的样式表,为未来的开发奠定了基础。

Changes

文件 更改摘要
crates/mako/src/build/load.rs UNSUPPORTED_EXTENSIONS 从包含 "sass"、"scss" 和 "stylus" 的数组减少至仅包含 "sass" 和 "stylus"。
crates/mako/src/resolve/mod.rs get_resolver 函数新增对 ".scss" 扩展名的支持。
crates/mako/src/visitors/virtual_css_modules.rs is_css_path 函数更新,增加对 .scss 扩展名的识别。
examples/with-sass/index.scss 新增样式文件,定义 h1 元素的样式及嵌套类 .blue
examples/with-sass/index.tsx 新增 React 应用程序入口文件,包含简单的组件结构和样式。
examples/with-sass/mako.config.json 新增 SASS 配置文件,基本框架为空对象。
examples/with-sass/package.json 新增依赖项配置,包含 React、ReactDOM 和 SASS。
examples/with-sass/public/index.html 新增 HTML 文件,定义了应用程序的基本结构和挂载点。
e2e/fixtures/sass.normal/src/index.tsx 更新样式应用方式,改用标准 CSS 直接引用。

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App
    participant CSSResolver
    User->>App: 请求加载组件
    App->>CSSResolver: 请求解析样式
    CSSResolver->>App: 返回样式
    App->>User: 渲染组件
Loading

Assessment against linked issues

Objective Addressed Explanation
修复 Mako 与 SassLoader 的集成问题 (#1476)
增强对 SCSS 文件的支持
解决样式模块引用方式的问题 未能解决样式模块和标准 CSS 的切换问题。

Poem

在草地上舞动的兔子,
看那 SASS 的鲜花绽放,
颜色缤纷如梦幻,
SCSS 的跳跃伴我歌唱。
样式新装,应用欢畅,
在代码中舞出希望的光。 🐰✨


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 711611d and 3e8195e.

Files selected for processing (8)
  • crates/mako/src/build/load.rs (1 hunks)
  • crates/mako/src/resolve/mod.rs (1 hunks)
  • crates/mako/src/visitors/virtual_css_modules.rs (1 hunks)
  • examples/with-sass/index.scss (1 hunks)
  • examples/with-sass/index.tsx (1 hunks)
  • examples/with-sass/mako.config.json (1 hunks)
  • examples/with-sass/package.json (1 hunks)
  • examples/with-sass/public/index.html (1 hunks)
Files skipped from review due to trivial changes (3)
  • examples/with-sass/index.scss
  • examples/with-sass/index.tsx
  • examples/with-sass/public/index.html
Additional comments not posted (5)
examples/with-sass/mako.config.json (1)

1-1: 文件创建成功!

该文件是一个简单的 JSON 配置,当前只包含一个空的 "sass" 对象。确保在未来需要时添加具体的配置。

examples/with-sass/package.json (1)

1-10: 依赖配置正确!

package.json 文件定义了项目的依赖关系。React 和 SASS 的版本选择合理。确保这些版本与项目的其他部分兼容。

crates/mako/src/visitors/virtual_css_modules.rs (1)

13-13: 扩展名识别更新成功!

is_css_path 函数现在支持 .scss 扩展名。这一更改符合对 SCSS 文件的支持目标。

crates/mako/src/build/load.rs (1)

41-41: 注意更新的支持文件扩展名

UNSUPPORTED_EXTENSIONS 常量中移除了 "sass" 和 "scss",这意味着这些文件类型现在被支持或不再被标记为不支持。请确保在其他相关代码中正确处理这些文件类型。

crates/mako/src/resolve/mod.rs (1)

384-384: 扩展 CSS 解析器以支持 SCSS

get_resolver 函数中添加了 ".scss" 扩展名,这使得解析器现在能够处理 SCSS 文件。这是对解析器功能的有益扩展。

@jeasonnow
Copy link
Contributor Author

本地 build 之后 link 到 global 验证 mako build --watch examples/with-sass 目录成功。在之前的版本验证不通过。

After

image
image

Before

image
image

@jeasonnow
Copy link
Contributor Author

#1476

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 3e8195e and eb47db9.

Files selected for processing (8)
  • crates/mako/src/build/load.rs (1 hunks)
  • crates/mako/src/resolve/mod.rs (1 hunks)
  • crates/mako/src/visitors/virtual_css_modules.rs (1 hunks)
  • examples/with-sass/index.scss (1 hunks)
  • examples/with-sass/index.tsx (1 hunks)
  • examples/with-sass/mako.config.json (1 hunks)
  • examples/with-sass/package.json (1 hunks)
  • examples/with-sass/public/index.html (1 hunks)
Files skipped from review due to trivial changes (4)
  • examples/with-sass/index.scss
  • examples/with-sass/mako.config.json
  • examples/with-sass/package.json
  • examples/with-sass/public/index.html
Files skipped from review as they are similar to previous changes (4)
  • crates/mako/src/build/load.rs
  • crates/mako/src/resolve/mod.rs
  • crates/mako/src/visitors/virtual_css_modules.rs
  • examples/with-sass/index.tsx

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 eb47db9 and a86807c.

Files selected for processing (8)
  • crates/mako/src/build/load.rs (1 hunks)
  • crates/mako/src/resolve/mod.rs (1 hunks)
  • crates/mako/src/visitors/virtual_css_modules.rs (1 hunks)
  • examples/with-sass/index.scss (1 hunks)
  • examples/with-sass/index.tsx (1 hunks)
  • examples/with-sass/mako.config.json (1 hunks)
  • examples/with-sass/package.json (1 hunks)
  • examples/with-sass/public/index.html (1 hunks)
Files skipped from review due to trivial changes (5)
  • examples/with-sass/index.scss
  • examples/with-sass/index.tsx
  • examples/with-sass/mako.config.json
  • examples/with-sass/package.json
  • examples/with-sass/public/index.html
Files skipped from review as they are similar to previous changes (3)
  • crates/mako/src/build/load.rs
  • crates/mako/src/resolve/mod.rs
  • crates/mako/src/visitors/virtual_css_modules.rs

@sorrycc
Copy link
Member

sorrycc commented Aug 8, 2024

merge 下 master 修下 ci,其他没有问题。

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 a86807c and de79e93.

Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing (8)
  • crates/mako/src/build/load.rs (1 hunks)
  • crates/mako/src/resolve/mod.rs (1 hunks)
  • crates/mako/src/visitors/virtual_css_modules.rs (1 hunks)
  • examples/with-sass/index.scss (1 hunks)
  • examples/with-sass/index.tsx (1 hunks)
  • examples/with-sass/mako.config.json (1 hunks)
  • examples/with-sass/package.json (1 hunks)
  • examples/with-sass/public/index.html (1 hunks)
Files skipped from review due to trivial changes (4)
  • examples/with-sass/index.scss
  • examples/with-sass/index.tsx
  • examples/with-sass/mako.config.json
  • examples/with-sass/public/index.html
Files skipped from review as they are similar to previous changes (4)
  • crates/mako/src/build/load.rs
  • crates/mako/src/resolve/mod.rs
  • crates/mako/src/visitors/virtual_css_modules.rs
  • examples/with-sass/package.json

@sorrycc
Copy link
Member

sorrycc commented Aug 8, 2024

有个用例挂了,本地执行 just ready 看下。

@jeasonnow
Copy link
Contributor Author

image
image

这个用例使用了 css module ,测试断言没有考虑产物 css module 的 className 是会附带 hash 的,我会去掉这个 css module 的用法。

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 de79e93 and 35327ed.

Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing (1)
  • e2e/fixtures/sass.normal/src/index.tsx (1 hunks)
Additional comments not posted (2)
e2e/fixtures/sass.normal/src/index.tsx (2)

2-2: 确认样式导入方式的改变。

将 SCSS 文件从 CSS 模块改为标准 CSS 导入,这可能影响样式的封装和作用域。请确认这一改变是有意为之,并符合项目的样式策略。


5-5: 验证类名使用的变化对样式封装的影响。

直接使用字符串作为类名,而不是引用 styles 对象,这与从 CSS 模块切换到标准 CSS 的改变一致。请确认这不会对样式封装产生负面影响。

@sorrycc sorrycc merged commit ca86ae6 into umijs:master Aug 9, 2024
12 checks passed
@jeasonnow jeasonnow deleted the fix/1476 branch August 12, 2024 05:59
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.

bug: Mako integration with SassLoader causing errors in Dumi
2 participants