-
Notifications
You must be signed in to change notification settings - Fork 186
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: make CSS preprocessor plugins compat with Rsbuild 1.2 #4909
fix: make CSS preprocessor plugins compat with Rsbuild 1.2 #4909
Conversation
✅ Deploy Preview for rsbuild ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
.rule(findRuleId(chain, CHAIN_ID.RULE.SASS_INLINE)) | ||
.test(include) | ||
.resourceQuery(/inline/); | ||
|
||
// Support for importing raw Sass files | ||
chain.module | ||
.rule(CHAIN_ID.RULE.SASS_RAW) |
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.
CHAIN_ID.RULE.SASS_RAW
is undefined
in v1.2.x. So we will get a rule like this:
/* config.module.rule('undefined') */
{
test: /\.s(?:a|c)ss$/,
resourceQuery: /raw/,
type: 'asset/source'
},
I'll make a patch in the next PR
.rule(CHAIN_ID.RULE.SASS_RAW) | |
.rule(CHAIN_ID.RULE.SASS_RAW ?? "sass-raw") |
callback(inlineRule, 'inline'); | ||
|
||
// Rsbuild < 1.3.0 does not have RULE.CSS_INLINE. | ||
if (chain.module.rules.has(CHAIN_ID.RULE.CSS_INLINE)) { |
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.
It might be preferable to use CHAIN_ID.RULE.CSS_INLINE && chain.module.rules.has(CHAIN_ID.RULE.CSS_INLINE)
because, theoretically, there could be a rule named undefined
.
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.
this will be better👍
// Rsbuild < 1.3.0 does not have RULE.CSS_INLINE. | ||
if (chain.module.rules.has(CHAIN_ID.RULE.CSS_INLINE)) { | ||
const inlineRule = chain.module | ||
.rule(findRuleId(chain, CHAIN_ID.RULE.LESS_INLINE)) |
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.
findRuleId should not be put inside the updateRules method. It should be only called once.
Summary
Ensure compatibility of plugin-less, plugin-sass, and plugin-stylus with Rsbuild 1.2.x.
Related Links
See lynx-family/lynx-stack#386.
Checklist