feat(plugin-sass): compatible with Rsbuild v1#7055
Conversation
Summary of ChangesHello @chenjiahan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Deploying rsbuild with
|
| Latest commit: |
605eaaa
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://a48e559d.rsbuild-v2.pages.dev |
| Branch Preview URL: | https://plugin-sass-0126.rsbuild-v2.pages.dev |
There was a problem hiding this comment.
Pull request overview
This PR adds support for Rsbuild v1 in the @rsbuild/plugin-sass by implementing version detection and conditional rule configuration. The plugin now maintains backward compatibility with Rsbuild v1.3.0+ while also supporting Rsbuild v2, avoiding the need for a major version bump.
Changes:
- Added version detection using
api.context.version.startsWith('1.')to conditionally handle v1 vs v2 rule structures - Removed SASS-specific CHAIN_ID constants from core (SASS_MAIN, SASS_RAW, SASS_INLINE) as they are now internally managed by the plugin
- Updated peer dependency requirement from
^1.0.0to^1.3.0to ensure thecontext.versionAPI is available
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/plugin-sass/src/index.ts | Implemented version detection and conditional rule configuration logic using a getRule helper function that maps between v1 flat rule structure and v2 oneOf rule structure |
| packages/core/src/configChain.ts | Removed SASS_MAIN, SASS_RAW, and SASS_INLINE constants from CHAIN_ID.ONE_OF as they are now plugin-internal |
| website/docs/en/config/tools/bundler-chain.mdx | Removed documentation for deprecated SASS ONE_OF chain IDs |
| website/docs/zh/config/tools/bundler-chain.mdx | Removed documentation for deprecated SASS ONE_OF chain IDs (Chinese version) |
| packages/plugin-sass/tests/index.test.ts | Added test case for Rsbuild v1 compatibility using the v1 dev dependency |
| packages/plugin-sass/tests/snapshots/index.test.ts.snap | Updated snapshots reflecting structural differences between v1 (flat rules) and v2 (oneOf rules), and added new v1-specific snapshot |
| packages/plugin-sass/package.json | Added @rsbuild/core-v1 dev dependency for testing and updated peer dependency to ^1.3.0 || ^2.0.0-0 |
| pnpm-lock.yaml | Updated lock file to include the new @rsbuild/core-v1 dev dependency |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Code Review
This pull request introduces compatibility for Rsbuild v1 in the plugin-sass package. The changes are well-structured, detecting the Rsbuild version and using a compatibility layer (getRule function) to handle differences in webpack rule configuration between v1 and v2. The decoupling of Sass-specific chain IDs from @rsbuild/core is a good move for maintainability. The addition of a new test case specifically for v1 ensures the changes are well-tested.
My review includes one suggestion to improve maintainability by removing redundant constants and relying on CHAIN_ID from @rsbuild/core for CSS-related rule names.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 67a49e880a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summary
Added support for Rsbuild v1 in
@rsbuild/plugin-sassby detecting the version and mapping rule IDs accordingly, ensuring that Sass processing works seamlessly across Rsbuild v1 and v2.Related Links
Checklist