-
Notifications
You must be signed in to change notification settings - Fork 69
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
Filename handling does not work with query strings and source maps #62
Comments
I spent hours trying to figure out why my CSS wasn't minified until I stumbled upon this. I'll have to use EDIT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I use query strings in Webpack to perform cache-busting instead of placing the hash directly in the file names. This generally works with other CSS and JS loaders, but fails when it gets to this plugin:
...
The resulting asset has the .map half of the file extension moved to the wrong place from where it was via MiniCssExtractPlugin:
/bundle.css?v=ee9422a65cc821d372b4.map 197 KiB [emitted]
This actually results in the .map file contents being written to the .css file location, overwriting it with no errors or warnings.
There seems to be a relatively straightforward initial fix in this plugin. There are two places where the map file is determined from the asset via:
assetName + '.map'
which is what results in the extension "migrating".
This could be changed to:
assetName.replace('.css', '.css.map')
Possibly with some fallbacks if we need to cover people who don't name their stylesheets with a .css extension...
This isn't a complete fix for my use case: the file names are correct again, but cssnano/PostCSS still ends up printing the following in the CSS file:
/*# sourceMappingURL=bundle.css?v=ee9422a65cc821d372b4.map */
This might be addressable here by fiddling with the annotation argument to cssnano, but I'm unsure if that should really be fixed here rather than proper query handling in PostCSS.
Thanks,
Alex
The text was updated successfully, but these errors were encountered: