-
Notifications
You must be signed in to change notification settings - Fork 167
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
[Bug]: SCSS/SASS Source Maps do not resolve @import directives #4451
Comments
Also added another SCSS file in the reproduction repo to test. The other file is properly shown in source maps so this only affects |
From what I understand about Sass, when using the @import syntax, all imports are merged into the main file, which may result in a source map that maps all styles to the main file (in this case index.scss). |
Maybe you can try other tools, such as webpack + sass-loader, I think we will see the same results |
I've had sourcemaps working before on |
I managed to get sourcemaps working with webpack quite easily - see: https://github.com/dretsa/rsbuild-webpack-scss-sourcemaps
|
Thanks for providing the webpack reproduction. After trying it, I can confirm that the Sass source map is broken by other loaders. In Rsbuild, both resolve-url-loader and lightningcss-loader cause this. If we disable these two loaders, we can get the same result in Rsbuild as the webpack demo. import { defineConfig } from '@rsbuild/core';
import { pluginSass } from '@rsbuild/plugin-sass';
export default defineConfig({
plugins: [
pluginSass({
rewriteUrls: false,
}),
],
output: {
sourceMap: true,
},
tools: {
lightningcssLoader: false,
},
}); But resolve-url-loader and lightningcss-loader both play important roles, we can't remove them from Rsbuild. |
Thank you for checking! I am not suggesting removing them at all. I had a quick look if LightningCSS supports sourcemaps and they have an option to pass in sass source maps using the
|
The To solve this issue, I think that we need to invest in two aspects:
|
Considering the main features of SASS are now supported with plain CSS I'm not sure how worth it is implementing this. If it's possible to fix the performance regressions with resolve-url-loader, I would be happy to fork it and help but I don't think this should be a high priority bug. I would only need some guidance where the performance regression is happening. |
I agree that this issue is not a high priority, so we cannot give a promised time to resolve it. |
Version
Details
When source maps are enabled for SCSS and you
@import
directive is used, the source is alwaysindex.scss
instead of the imported file.I am using the defaults for the most part, the only change is
output.sourceMap.css: true
. I have also tried setting allsassLoaderOptions.sassOptions.sourceMap*: true
- no effect. It seems like source maps for CSS -> SCSS and CSS extraction are working but the SCSS source maps are not properly output.I am using bootstrap - I can provide a quick repo with reproduction.
Reproduce link
https://github.com/dretsa/rsbuild-scss-sourcemap-bug
Reproduce Steps
npm ci
npm run dev
The text was updated successfully, but these errors were encountered: