bootstarted / css-split-webpack-plugin

Split your CSS for stupid browsers using webpack and postcss.
78 stars 22 forks source link

Handle case where there are no source maps. #24

Closed izaakschroeder closed 6 years ago

izaakschroeder commented 6 years ago

This turns out to be really hard to do in practice. Generally speaking any time you use ExtractTextPlugin you get a ConcatSource which always has sourceAndMap available. The only case you don't get a source map is when another plugin generates a CSS file that uses RawSource or something similar. One such plugin is optimize-css-assets-webpack-plugin when you don't tell the CSS processor to generate a source map (e.g. cssProcessorOptions has no map entry).

foo.styl -> foo.css -> ExtractTextPlugin
bar.styl -> bar.css ---^

Everything goes into ExtractTextPlugin and that ALWAYS generates something with a source map, even if it’s an empty one. The issue here is your css optimizer; it goes:

ExtractTextPlugin -> Optimizer -> Splitter

And that kills everything.

Original PR from @didi0613 here: https://github.com/metalabdesign/css-split-webpack-plugin/pull/23 We just include a test in this one and a bit more of an investigation into why things happened the way they did.

didi0613 commented 6 years ago

lgtm!