-
-
Notifications
You must be signed in to change notification settings - Fork 259
[Bug]: @plugin-sass // Single-line comment incorrectly strips properties; presence of second // comment causes abnormal compilation behavior #6473
Description
Version
System:
OS: Windows 11 10.0.26100
CPU: (16) x64 13th Gen Intel(R) Core(TM) i7-13620H
Memory: 3.10 GB / 15.75 GB
Browsers:
Chrome: 141.0.7390.123
Edge: Chromium (140.0.3485.54)
Internet Explorer: 11.0.26100.1882
npmPackages:
@rsbuild/core: ^1.5.17 => 1.6.0
@rsbuild/plugin-babel: ^1.0.6 => 1.0.6
@rsbuild/plugin-sass: ^1.4.0 => 1.4.0
@rsbuild/plugin-vue: ^1.2.0 => 1.2.0
@rsbuild/plugin-vue-jsx: ^1.1.1 => 1.1.1Details
We are encountering a severe and non-standard bug when using the official @rsbuild/plugin-sass to process SCSS files. When a style block contains two // single-line comments, the properties between them are incorrectly removed, but the property following the second comment is preserved.
Crucially, removing the second // comment resolves the entire issue, indicating an unstable parser state management within the plugin when handling SCSS's line-stripping comments.
Steps to Reproduce
Set up an Rsbuild project using the following environment details.
Add the following code to an .scss file (This is the only scenario exhibiting the bug):
SCSS
// SCSS Source Code (Matching the user-provided image)
a {
// display: flex; // <-- First // comment (Bug Start)
min-height: 100vh;
line-height: 1.1; // <-- Properties that are stripped
// text-align: center;// <-- Second // comment (Bug Stop/Anomaly)
flex-direction: column;// <-- This property is preserved
justify-content: center;
}
Actual Behavior (Observed Bug)
With Two // Comments (As above): The properties padding, color, and font-weight are incorrectly stripped from the final CSS output. However, border-radius: 3px; is preserved.
Key Observation (The Anomaly and Fix)
The Fix: When the second comment, // text-align: center;, is removed, the bug is resolved, and all properties compile correctly into the final CSS.
Inference: The very presence of the second // comment is what causes the properties between the two comments to be stripped, while simultaneously protecting the final property. This points to a severe bug in the line-counting or state-reset logic of the SASS compilation pipeline within @rsbuild/plugin-sass.
Suggested Workaround
The only reliable way to proceed is to replace all // comments used for disabling properties with standard CSS block comments /* ... */.
Reproduce link
Reproduce Steps
npm run dev