-
-
Notifications
You must be signed in to change notification settings - Fork 30
Source map content from previous processing step is ignored #134
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
Expected, same logic for all minimizers and no problems, what is the problem? Previously source map consumed by webpack itself for generate valid source maps |
https://github.com/webpack-contrib/css-minimizer-webpack-plugin/blob/master/src/index.js#L360 line for apply minimizer code on original, as you can see we have |
Ok after some deeper tests I've found the real issue come from the filename param that contains a directory param given to mini-css-extract-plugin: - plugins: [new MiniCssExtractPlugin()],
+ plugins: [
+ new MiniCssExtractPlugin({
+ filename: `css/[name].css`,
+ }),
+ ], Here the matrix of options given to
|
Please create reproducible test repo and I will look, do not ignore this field |
Ok, you will find a reproducible test here: webpack-source-map-merge-test |
hm, yes, postcss not respect input filename, no problems with |
Bug report
When css-minimizer-webpack-plugin is used, source map content from previous step is ignore and completely replaced and not merge with the one that came from minification.
Actual Behavior
In debug mode, you can inspect the DOM elements in the browsers devtool and see the original source of applied rulesets.
In release mode, due css-minimizer-webpack-plugin apply minification, you only see the source before minification, not the original one.
Expected Behavior
When you inspect DOM elements in the browsers devtool you can see the original source of applied rulesets in any mode (release, debug, etc.)
How Do We Reproduce?
Compile styles with a preprocessor (sass, less, stylus, etc.) with sourcemap without css-minimizer-webpack-plugin (or disabled with debug mode), inspect the extracted source map with devtool or source-map-visualization.
Do it again but with css-minimizer-webpack-plugin, then it inspect again.
Reproducible test: webpack-source-map-merge-test
Please paste the results of
npx webpack-cli info
here, and mention other relevant informationPossible solutions
Each minimizer has it's own option/solution:
postcssOptions.map.prev = inputSourceMap
output.map.applySourceMap(await new SourceMapConsumer(inputSourceMap), filename)
new CleanCSS({sourceMap: Boolean(inputSourceMap), ...minimizerOptions}).minify({[name]: {styles: code}}, inputSourceMap)
code = `${code}\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,${btoa(inputSourceMap)}`
It's also possible to not provide previous source map to the minimizer but instead manually merge source maps:
Example of implementation with cssnano:
The text was updated successfully, but these errors were encountered: