-
-
Notifications
You must be signed in to change notification settings - Fork 603
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
Source map is incorrect if passed minimized css code #381
Comments
@x-yuri Does this still happen with latest |
@michael-ciniawsky Yes, it reproduces with
{
"dependencies": {
"css-loader": "^0.28.2",
"html-webpack-plugin": "^2.28.0",
"node-sass": "^4.5.3",
"sass-loader": "^6.0.5",
"style-loader": "^0.18.1",
"webpack": "^2.6.0"
}
}
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: './1.js',
output: {
path: path.resolve('dist'),
filename: 'bundle.js',
},
module: {
rules: [
{test: /\.scss$/, use: [
'style-loader',
{loader: 'css-loader', options: {sourceMap: true}},
{loader: 'sass-loader', options: {sourceMap: true, outputStyle: 'compressed'}},
]},
],
},
plugins: [
new HtmlWebpackPlugin({
template: 'template.ejs',
}),
],
}; With this,
Just tell me what exactly is it you want to know. I believe I've described everything I possibly could. |
@x-yuri Not related to |
@evilebottnawi Where do you see nested styles in |
@x-yuri this bug related to change |
@evilebottnawi I see nothing wrong with what
Open this link, paste the code above into Output field, click Analyze and use Right/Left arrows to navigate. Let's just say, |
I have the same problem, did you find any solution ? |
I've just rechecked my test case. I can reproduce it with Webpack 1, 2, and 3. Steps to reproduce:
And display styles for Which is still wrong :) But inspecting resulting css: body{background:#ddd}div{width:100px;height:100px;margin:auto;background:#666}
/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9zcnYvaHR0cC9zMS9teS13ZWJwYWNrLTMvMS5zY3NzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLEtBQ0ksZUFBZ0IsQ0FDbkIsSUFFRyxZQUNBLGFBQ0EsWUFDQSxlQUFnQixDQUNuQiIsImZpbGUiOiIxLnNjc3MiLCJzb3VyY2VzQ29udGVudCI6WyJib2R5IHtcbiAgICBiYWNrZ3JvdW5kOiAjZGRkO1xufVxuZGl2IHtcbiAgICB3aWR0aDogMTAwcHg7XG4gICAgaGVpZ2h0OiAxMDBweDtcbiAgICBtYXJnaW46IGF1dG87XG4gICAgYmFja2dyb3VuZDogIzY2Njtcbn1cbiJdLCJzb3VyY2VSb290IjoiIn0= */ here (put css into Output field and click Analyze, then use Left/Right arrows, more on it here) shows that there're not many options for a browser to choose from. No mapping to line 4 exists in the resulting source map. But if we take body{background:#ddd}div{width:100px;height:100px;margin:auto;background:#666}
/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9zcnYvaHR0cC9zMS9teS13ZWJwYWNrLTMvMS5zY3NzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLEFBQUEsSUFBSSxBQUFDLENBQ0QsVUFBVSxDQUFFLElBQUksQ0FDbkIsQUFDRCxBQUFBLEdBQUcsQUFBQyxDQUNBLEtBQUssQ0FBRSxLQUFLLENBQ1osTUFBTSxDQUFFLEtBQUssQ0FDYixNQUFNLENBQUUsSUFBSSxDQUNaLFVBQVUsQ0FBRSxJQUFJLENBQ25CIiwiZmlsZSI6IjEuc2NzcyIsInNvdXJjZXNDb250ZW50IjpbImJvZHkge1xuICAgIGJhY2tncm91bmQ6ICNkZGQ7XG59XG5kaXYge1xuICAgIHdpZHRoOiAxMDBweDtcbiAgICBoZWlnaHQ6IDEwMHB4O1xuICAgIG1hcmdpbjogYXV0bztcbiAgICBiYWNrZ3JvdW5kOiAjNjY2O1xufVxuIl0sInNvdXJjZVJvb3QiOiIifQ== */ That's a different story. @evilebottnawi So you're saying it's @JiDai I've switched to postcss. But for a different reason. |
Well, it turns out even with
body {
background: #ddd;
}
div {
width: 100px;
height: 100px;
margin: auto;
background: #666;
}
<!doctype html>
<html>
<body>
<link rel="stylesheet" href="1.css">
<div></div>
</body>
</html>
body{background:#ddd}div{width:100px;height:100px;margin:auto;background:#666}
/*# sourceMappingURL=1.css.map */
If we now create a copy of
It works. Chromium refers to line 4. So, it must be safe to assume, that the issue has been resolved on the browsers' end. They choose next segment after the bracket. It's only the fact that |
package.json
:webpack.config.js
:template.ejs
:1.js
:1.scss
After
sass-loader
we get the following css code:and mappings:
which are pretty fine to me.
But after
css-loader
what we got are the same css code, but different mappings:and Chrome reports the wrong line (no mapping for line 4 above in terms of Chrome):
P.S.
node-7.1.0
, Arch LinuxThe text was updated successfully, but these errors were encountered: