postcss-loader icon indicating copy to clipboard operation
postcss-loader copied to clipboard

Unclear setup of source maps

Open Arhane opened this issue 9 years ago • 1 comments

I have been trying to set up sourceMaps with the last version of postcss-loader. And it got really messy.

I set up sourceMap=true in webpack config, and I set up map="inline" in postcss.config.js .

If I remove sourceMap=true, source maps don't work. If I remove map="inline", source maps don't work correctly. My main concern is that we configure the source map usage in two different places and that doesn't get along with the SRP.

I suggest to remove sourceMap from webpack config, that way it will only stay in postcss config with other plugins and options.

P.S. Is the environment (npm, node, etc...) important here?

Arhane avatar Dec 01 '17 19:12 Arhane

You can't configure source maps via postcss.config.js (remove it anything related to source maps entirely from the config file please) when using postcss-loader (webpack), since webpack sets [strict] requirements about the source map generation (format). The 90% correct way to go is simply using sourceMap: true in webpack.config.js's postcss-loaderoptions.sourceMap: inline can be used with style-loader && postcss-loader (standalone, no css-loader) so the source map is inlined in the CSS source as an annotation comment /*# sourceMappingURL= ... */ which loads faster in development.

TL:DR remove all source map related props from postcss.config.js && use sourceMap: true in webpack.config.js postcss-loader options

Feel free to reopen if still regressions

michael-ciniawsky avatar Dec 01 '17 20:12 michael-ciniawsky