-
-
Notifications
You must be signed in to change notification settings - Fork 210
Wrong SourceMap genrated #434
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
Comments
Bug on |
But if I disable postcss loader,the problem goes away. |
Oh, yep, I was misleading, it is bug in postcss, because postcss, don't know how generate absolute sources, let's keep open |
@zq1997 maybe you can create minimum reproducible test repo, just want to add tests on this case? |
Just three reproducible files, (too lazy to create a repo) {
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack -c webpack.config.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"css-loader": "^3.6.0",
"mini-css-extract-plugin": "^0.9.0",
"postcss-loader": "^3.0.0",
"sass": "^1.26.10",
"sass-loader": "^9.0.2",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.12"
}
} webpack.config.js const webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
mode: "development",
entry : {
test: './src/test.css',
},
devtool: 'source-map',
plugins: [
new MiniCssExtractPlugin(),
],
module: {
rules: [
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
sourceMap: true
}
},
{
loader: 'postcss-loader',
options: {
plugins: [],
sourceMap: true
}
},
// enable sass-loader will make source-map work properly.
// "sass-loader"
]
}
]
}
} src/test.css body {
margin: 0;
} Then npm start
cat dist/test.css.map GOT
with
the differnces is directory name |
Ops, these files cannot reproduce But if I disable postcss loader,the problem goes away., sorry but my origin repository is too complex... |
Thanks! |
I wrote an module.exports = function(source, map, meta) {
console.log(map);
this.callback(null,source,map,meta);
} apply the loader path.resolve('./nop-loader.js'),
{
loader: 'postcss-loader',
options: {
plugins: [],
sourceMap: true
}
},
path.resolve('./nop-loader.js'),
// enable sass-loader will make source-map work properly.
"sass-loader" The result make me a little confused, why there is two sources? and relative path became absolute
|
My original project is writen in Vue, I also print the sourcemap result of
the absolute path is wrong becuase |
Bug here, it is invalid use |
And this problem is caused by https://github.com/postcss/postcss-loader/blob/master/src/index.js#L141 line. postcss return source map with |
Yes, we need fix it |
Let's close in favor #390, we need |
The source maps specification only supports relative or absolute URLs in the
An absolute URL means an actual fully qualified It should be Webpack's responsibility to transform that properly.
And done. The issue with ALL these loaders for CSS, PostCSS, Less and SASS is not with the third party tooling. |
@rjgotten it is job of |
Yes, sources should be URL, but no one tool supports merging sources maps using |
If you have a problems right now please create reproducible test repo, note - |
No tool would ever need to. According to spec, a source map's Once Webpack finishes combining them, you still have relative URLs in the sourcemap and the only thing Webpack has to do is populate the final combined source map's The only issue that exists with this, are pre-generated source maps that ship with absolute URLs. The answer to that property of the problem is simple: just pass them through. Let them flow through unaltered and they'll end up 'as is' in the final source map. The behavior for resolving If a pre-generated source map has an absolute URL in its
I have problems with you insinuating that PostCSS itself has an actual bug here which needs to be patched. When clearly it's Webpack and its loaders which have ass-backwards behavior. And on a wider scale I have issues with Webpack foregoing to fix the root of the problem and instead choosing for a litany of workarounds at the individual loader level; to convert valid source maps into the intentionally invalid source maps -- 'pseudo source maps' ? -- that Webpack expects. If you implement support for a standard, damn well implement support for the standard. Don't cook your own idea of it. |
You just said that I don't want to be involved in a toxic non-constructive talk. I asked you to look at the code of |
Apparently since that time, many still have not learned to communicate |
postcss/postcss#1348 Need more links? |
Can you just explain your problem? We using |
Details
Wrong SourceMap genrated
Reproduction (Code)
generated sourcemap has wrong path
test.css
instead of./src/test.css
Environment
The text was updated successfully, but these errors were encountered: