You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
nested styles refer to top-level parent in sourcemap line number #272
I encountered the same issue in sass/node-sass#1206.
But according to this post, this issue has been fixed in node-sass, but it still occurred with sass-loader.
This is my sass-loader config: 'style!css?sourceMap!sass?sourceMap=true&outputStyle=expanded&sourceMapContents=true'
Any help?
Reacted by folmert, Will Colton, David Krutsko, Laura Lee, Adam Szmyd, Mohammad Ebrahimi Aval, Léo Chéron, Fredrik Blomqvist and Mark Slade
CSS source maps can only work if every loader in the loader chain passes them through. That's necessary because webpack, only supports JS source maps out of the box.
@woohling Do you experience the same issue when you use this loader chain: style-loader?sourceMap!css-loader?sourceMap!sass?sourceMap&outputStyle=expanded&sourceMapContents=true'
?
@jhnns Could you explain more on "we don't actually mess with the source maps". Are you saying that sass-loader doesn't create the source maps. If so then what does and how?
As mentioned running "node-sass" in the terminal the source maps are fine, but running it though sass-loader and webpack they are not.
Sorry I am not too familiar with sass-loader flow. Could someone explain the difference that running sass-loader through webpack has as compared to running node-sass through the terminal.
It almost seems like the scss file is converted to (nested, expanded, or compact) prior to the source map is being applied then the css is compressed.
Is there any way to test that sass-loader is getting the full un-compacted un-compressed scss files when creating the source mappings?
We receive the source maps directly from node-sass. But since the source maps are also processed by the css-loader and other loaders on the way, it's hard to say what's going on. Maybe they are incompatible?
It would be good if you could investigate this. Build the smallest project possible that reproduces the error and inspect the source maps in the sass-loader and then in the css-loader. You can use the style-loader to apply the styles to the DOM. The style-loader uses a BLOB url to make the source maps available to the browser. It does not change the source maps anymore, so that should be fine.
Sorry @jhnns@evilebottnawi, I took a pause from this project.
Nope, the issue still exists for me. I also just recently installed brand new ng-cli on a new laptop.
Angular4.0 with CLI 1.0.2 which is using sass-loader 6.0.3
I created a small project and just had a few lines of scss code.
It still pointed to the top parent node, but running node-sass works fine.
Not sure what I can do to help further.
In short: browsers always show first selector in sequence nested selectors in source maps. I am closing this issue here because it is not related to sass-loader and we don't have time to fix this in other packages (libsass) which not related directly to webpack. Your can create new issue or write post in sass/libsass#1747 if your think it is can be fixed.
Btw your can click in dev tools on property to move in right position in source maps.
Closing issue, because not related, sorry, but i can't do anything here 😞
Based issue: postcss/postcss#926
Why it is happens: postcss/postcss#926 (comment)
Workaround: implement own loader which correct this behavior (difficult).
currently with this set up the source map would only be pretty darn close to the line in the scss file when I am inspecting through chrome console. Don't know if anyone else is seeing this as well.
I'm experiencing this issue now as well. Source map always end up referring to the top-level parent instead of to the actual line. Our setup is quite simple:
Setting sassOptions: { outputStyle: 'compressed' } on sass-loader does not improve the situation. If I do that, the source map will even link to the wrong files (not just wrong lines).
Running node-sass using the CLI works well, it outputs correct source-maps for nested classes no matter which outputStyle is selected.
We're on pretty much the latest version of everything:
Any ideas of why this could be happening? I could try to put together a demo repo if needed.
Looks like @evilebottnawi had some insight on this before?
Activity
ggedde commentedon Oct 28, 2016
Mac OSX (El Capitan?)
"sass-loader": "^4.0.2",
"webpack": "^2.1.0-beta.25",
"webpack-dev-server": "^2.1.0-beta.0"
node: 6.7.0
When running the SCSS SourceMaps only point to the Parent selector and not the correct selector.
But as you can see it is not pointing to the correct selector. It should be pointing to line 13 not line 5.
However,
If I run 'node-sass' in the terminal then it works fine. So it seems to be an issue with sass-loader and webpack.
Any solutions to resolve this or is there any settings in node-modules/sass-loader that I can change to get different results.
Thanks
folmert commentedon Nov 24, 2016
Same problem here. Did anyone found a workaround for this?
jhnns commentedon Nov 25, 2016
CSS source maps can only work if every loader in the loader chain passes them through. That's necessary because webpack, only supports JS source maps out of the box.
@woohling Do you experience the same issue when you use this loader chain:
style-loader?sourceMap!css-loader?sourceMap!sass?sourceMap&outputStyle=expanded&sourceMapContents=true'?
woohling commentedon Nov 25, 2016
Just tried, but still the same problem. 😥 @jhnns
folmert commentedon Nov 26, 2016
I switched from sass-loader to postcss/precss and source maps are generated correctly now, so there must be something broken in sass-loader.
maximusnikulin commentedon Dec 28, 2016
Did anyone solve this problem?
pgayvallet commentedon Jan 4, 2017
Same issue here. @import makes sourcemap point to the parent file.
jhnns commentedon Feb 13, 2017
I can confirm the problem. You can test that with ce198d1 and
npm run test-source-map.Unfortunately, I don't know how to fix this since we don't actually mess with the source maps.
ggedde commentedon Feb 13, 2017
@jhnns Could you explain more on "we don't actually mess with the source maps". Are you saying that sass-loader doesn't create the source maps. If so then what does and how?
As mentioned running "node-sass" in the terminal the source maps are fine, but running it though sass-loader and webpack they are not.
Sorry I am not too familiar with sass-loader flow. Could someone explain the difference that running sass-loader through webpack has as compared to running node-sass through the terminal.
It almost seems like the scss file is converted to (nested, expanded, or compact) prior to the source map is being applied then the css is compressed.
Is there any way to test that sass-loader is getting the full un-compacted un-compressed scss files when creating the source mappings?
jhnns commentedon Feb 14, 2017
We receive the source maps directly from node-sass. But since the source maps are also processed by the css-loader and other loaders on the way, it's hard to say what's going on. Maybe they are incompatible?
It would be good if you could investigate this. Build the smallest project possible that reproduces the error and inspect the source maps in the sass-loader and then in the css-loader. You can use the style-loader to apply the styles to the DOM. The style-loader uses a BLOB url to make the source maps available to the browser. It does not change the source maps anymore, so that should be fine.
alexander-akait commentedon May 3, 2017
@woohling @maximusnikulin @wayofspark @ggedde The problem still exists? If yes please create minimal reproducible test repo
woohling commentedon May 4, 2017
No longer working on the project with this issue.
But I will find time to create a small demo to see if the problem still exists.
alexander-akait commentedon May 4, 2017
@woohling just ping me when your do this 👍
ggedde commentedon May 9, 2017
Sorry @jhnns @evilebottnawi, I took a pause from this project.
Nope, the issue still exists for me. I also just recently installed brand new ng-cli on a new laptop.
Angular4.0 with CLI 1.0.2 which is using sass-loader 6.0.3
I created a small project and just had a few lines of scss code.
It still pointed to the top parent node, but running node-sass works fine.
Not sure what I can do to help further.
23 remaining items
alexander-akait commentedon Aug 16, 2017
@woohling @ggedde @folmert @wayofspark @sandwich @aszmyd won't fix in
sass-loader😞Information about why this happens: sass/libsass#1747 (comment) and sass/libsass#1747 (comment).
In short: browsers always show first selector in sequence nested selectors in source maps. I am closing this issue here because it is not related to
sass-loaderand we don't have time to fix this in other packages (libsass) which not related directly towebpack. Your can create new issue or write post in sass/libsass#1747 if your think it is can be fixed.Btw your can click in dev tools on
propertyto move in right position in source maps.aszmyd commentedon Aug 17, 2017
@evilebottnawi im not sure this is the right decision.
sass-loaderis usingnode-sass.node-sassis:And in one of my earlier posts i've created small repo that uses only
node-sassand it works perfectly fine.So question is - why pure
node-sassis working properly butsass-loaderthat is using it underneath, is not?alexander-akait commentedon Aug 17, 2017
@aszmyd your can look loader code, we don't modify source map from
node-sass.Just confirm:
console.log(result.map.toString())in https://github.com/webpack-contrib/sass-loader/blob/master/lib/loader.js#L60{ "version": 3, "file": "stdin.css", "sourceRoot": "/home/evilebottnawi/IdeaProjects/webpack-sass-loader-sourcemap-issue", "sources": [ "stdin" ], "sourcesContent": [ "html {\n background: rgba(0, 0, 0, 0.7);\n}\n\nbody {\n\n h1 {\n color: white;\n }\n}\n" ], "names": [], "mappings": "AAAA,AAAA,IAAI,CAAC;EACD,UAAU,EAAE,kBAAkB,GACjC;;AAED,AAEI,IAFA,CAEA,EAAE,CAAC;EACC,KAAK,EAAE,KAAK,GACf" }{ "version":3, "sources":["webpack:///./src/src/index.scss"], "names":[], "mappings":"AAAA;EACI,+BAA8B,EACjC;;AAED;EAGQ,aAAY,EACf", "file":"styles/index.css", "sourcesContent":["html {\n background: rgba(0, 0, 0, 0.7);\n}\n\nbody {\n\n h1 {\n color: white;\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/src/index.scss"],"sourceRoot":""}Seems something invalid in
mappings, but it is notsass-loader, let's investigate this, thanks!alexander-akait commentedon Aug 17, 2017
@aszmyd something wrong in
css-loader😞style-loadertowebpack.config.jsloaders: [ { test: /\.scss$/, /*use: ExtractTextPlugin.extract({*/ use: [{ loader: 'style-loader', options: { sourceMap: true } }, { loader: 'css-loader', options: { sourceMap: true } }, { loader: 'sass-loader', options: { sourceMap: true // outputStyle: 'compressed' } }] /* })*/ } ]node_modules/css-loader)npm run startand your can see that source map is validalexander-akait commentedon Aug 17, 2017
Problem in
postcss, which using incss-loader, I'll try to updatepostcssto the latest version incss-loaderand see what happensalexander-akait commentedon Aug 17, 2017
Closing issue, because not related, sorry, but i can't do anything here 😞
Based issue: postcss/postcss#926
Why it is happens: postcss/postcss#926 (comment)
Workaround: implement own loader which correct this behavior (difficult).
Maybe we can fix this in https://github.com/mozilla/source-map, your can create issue there with examples (prefer where only
node-sassandpostcsswithoutwebpack- easy debug), thanks!ggedde commentedon Sep 2, 2017
Hi @evilebottnawi ,
Thanks for all the hard work on this. I know you wanted this sooner, but here is my repo:
https://github.com/ggedde/ngtest
It just uses AngularCLI (Requires Node and NPM)
After NG finishes then Navigate your browser to http://localhost:4200
You will see that if you instead the <h1> that the color points to line 3 in the inspector, but is actually on line 9. This issue is on both Chorme and Firefox.
However, if you add:
To the sass-loader [options] in "node_modules/@angular/cli/models/webpack-configs/styles.js"
Then it works fine in Chrome, but not Firefox.
Hope this helps others.
Thanks
alexander-akait commentedon Sep 2, 2017
@ggedde thanks!
kevin074 commentedon Dec 1, 2018
currently with this set up the source map would only be pretty darn close to the line in the scss file when I am inspecting through chrome console. Don't know if anyone else is seeing this as well.
SweetsXob commentedon Jul 10, 2019
This problem does not seem to be solved now.
It seems less doesn't have this problem
fgblomqvist commentedon Jan 23, 2020
I'm experiencing this issue now as well. Source map always end up referring to the top-level parent instead of to the actual line. Our setup is quite simple:
Setting
sassOptions: { outputStyle: 'compressed' }onsass-loaderdoes not improve the situation. If I do that, the source map will even link to the wrong files (not just wrong lines).Running
node-sassusing the CLI works well, it outputs correct source-maps for nested classes no matter whichoutputStyleis selected.We're on pretty much the latest version of everything:
Any ideas of why this could be happening? I could try to put together a demo repo if needed.
Looks like @evilebottnawi had some insight on this before?
MichaelDWheeler commentedon Oct 30, 2020
This resolved it for me:
I found it here:
https://github.com/noreading/bootstrap4-webpack-boilerplate/blob/master/webpack.config.js
you may have to pass argv into module.exports like it is on the page I linked.