GoogleChromeLabs / critters

🦔 A Webpack plugin to inline your critical CSS and lazy-load the rest.
https://npm.im/critters-webpack-plugin
Apache License 2.0
3.42k stars 108 forks source link

Duplicated styles when using `additionalStylesheets` option #88

Open rschristian opened 2 years ago

rschristian commented 2 years ago

The test added in #87 acts as a reproduction.

The basic gist of the issue is that the pattern used for additionalStylesheets can match the main CSS file, which causes its styles to be duplicated.

If we use a pattern like *.css, the sheet's contents will be added once from additionalStylesheets() and again from embedLinkedStylesheets().

It seems that in the past the use of cssnano deduped these styles and hid the issue, though the current solution doesn't offer that same benefit.

Not sure whether this is a regression or just chance behavior that was relied upon.

developit commented 2 years ago

I've run into this as well in the past week.

developit commented 2 years ago

It looks like we'll need to bring back the option of running stylesheets through cssnano.