-
-
Notifications
You must be signed in to change notification settings - Fork 426
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
nested styles refer to top-level parent in sourcemap line number #272
Comments
Mac OSX (El Capitan?) 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, Any solutions to resolve this or is there any settings in node-modules/sass-loader that I can change to get different results. Thanks |
Same problem here. Did anyone found a workaround for this? |
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: |
Just tried, but still the same problem. 😥 @jhnns |
I switched from sass-loader to postcss/precss and source maps are generated correctly now, so there must be something broken in sass-loader. |
Did anyone solve this problem? |
Same issue here. @import makes sourcemap point to the parent file. |
I can confirm the problem. You can test that with ce198d1 and Unfortunately, I don't know how to fix this since we don't actually mess with the source maps. |
@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? 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. |
@woohling @maximusnikulin @wayofspark @ggedde The problem still exists? If yes please create minimal reproducible test repo |
No longer working on the project with this issue. |
@woohling just ping me when your do this 👍 |
Sorry @jhnns @evilebottnawi, I took a pause from this project. I created a small project and just had a few lines of scss code. |
@ggedde can your create minimal reproducible test repo? |
@evilebottnawi In the meantime I did find that if I added So my guess is that css-loader is expecting the sass-loader to be compressed. So if sass-loader is not then you need to specify it. I am not sure how to have css-loader know what the format is. That way you wouldn't have to specify it. So this may be an issue with css-loader and not sass-loader. I will look at it again later tonight. |
@ggedde seems bugs not in |
Yes, FF has a bug, but Chrome doesn't work either unless you add outputStyle: 'compressed' to sass-loader. There may not be a bug with either, but there is definitely a configuration issue that is not well documented anywhere. Nor does anyone have a good grasp on how to configure css-loader with sass-loader to make the sourcemaps work properly. It would be great for us to figure it out then either someone from the sass-loader team or css-loader team right a blog post about it explaining the reasons why and how to properly configure webpack to output the correct sourcemaps. I will definitely do what I can to support it. |
I may be reading things incorrectly here, but I think y'all might be barking up the wrong tree if you're looking for the origin of the problem to be in See, I have this exact issue, of sourcemaps not referencing the right line if the Does this help any? |
@sandwich can your provide minimum reproducible test repo? |
Here ya go (not precisely minimum; I wanted it to be self-explanatory, too). Once extracted, run Reproducible in Chrome, Firefox, IE11, and Edge (i.e. it's not a browser issue). |
I've made an reproducible test repo using The issue is present there: Even using |
@aszmyd thanks, in near future i try to investigate this! |
@aszmyd invalid configuration.
In your test repo i have correct position. Can your provide more information your node version, npm, OS and etc? |
@aszmyd reproduce, thanks, looking. Tomorrow I will write what was the problem |
@evilebottnawi Perhaps you missed my earlier post. I have the exact same issue, except I'm not using webpack, but gulp. Therefore, there's a decent chance that the issue is not in anything specifically related to webpack, but is rather in Sass or the Sass Sourcemaps code, since that's the only common denominator. |
@aszmyd I have a test case as a zip up above, using |
@sandwich i've checked You'r code and figured out that the part that is messing around with things is So changed sass task that works:
So my guess is that its more |
@aszmyd doing at this moment 😄 |
Btw seems bug did not located in |
@woohling @ggedde @folmert @wayofspark @sandwich @aszmyd won't fix in 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 Btw your can click in dev tools on |
@evilebottnawi im not sure this is the right decision.
And in one of my earlier posts i've created small repo that uses only So question is - why pure |
@aszmyd your can look loader code, we don't modify source map from
{
"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 |
@aszmyd something wrong in
loaders: [
{
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'
}
}]
/* })*/
}
]
/*map = result.map;
if(map.sources) {
map.sources = map.sources.map(function(source) {
return source.split("!").pop().replace(/\\/g, '/');
}, this);
map.sourceRoot = "";
}
map.file = map.file.split("!").pop().replace(/\\/g, '/');*/
|
Problem in |
Closing issue, because not related, sorry, but i can't do anything here 😞 Maybe we can fix this in https://github.com/mozilla/source-map, your can create issue there with examples (prefer where only |
Hi @evilebottnawi , It just uses AngularCLI (Requires Node and NPM)
After NG finishes then Navigate your browser to http://localhost:4200 However, if you add:
To the sass-loader [options] in "node_modules/@angular/cli/models/webpack-configs/styles.js" Hope this helps others. |
@ggedde thanks! |
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.
|
This problem does not seem to be solved now. |
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: {
test: /\.(s?css)$/,
use: [{
loader: MiniCssExtractPlugin.loader,
}, {
loader: 'css-loader',
options: {
sourceMap: true,
},
}, {
loader: 'sass-loader',
options: {
sourceMap: true,
},
}]
}, Setting Running 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. |
This resolved it for me:
I found it here: you may have to pass argv into module.exports like it is on the page I linked. |
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?
The text was updated successfully, but these errors were encountered: