-
-
Notifications
You must be signed in to change notification settings - Fork 212
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
Plugins run twice on css modules #70
Comments
Ok, narrowed to madyankin/postcss-modules/issues/70 |
Also using CSS modules composition could result in a bunch of duplicate rules. /* Shared.css */
.test {
content: 'test';
}
/* Foo.css */
.foo {
composes: test from './Shared.css';
}
/* Bar.css */
.bar {
composes: test from './Shared.css';
} Result: .Shared-test {
content: 'test';
}
.Foo-foo {}
.Shared-test {
content: 'test';
}
.Bar-bar {} |
I ran into this issue today, was there a fix for this? |
I found that changing https://github.com/egoist/rollup-plugin-postcss/blob/master/src/postcss-loader.js#L75 from |
Fixes egoist#70 If the postcss-modules plugin isn't placed first we end up with non-modularized rules along with modularized rules. This situation thus leads to heavier bundles due to code duplication that end up dead and, when the extract option is set to false, it can cause conflicts with other non-modularized (global) rules present in the bundle consumer code.
Fixes #70 If the postcss-modules plugin isn't placed first we end up with non-modularized rules along with modularized rules. This situation thus leads to heavier bundles due to code duplication that end up dead and, when the extract option is set to false, it can cause conflicts with other non-modularized (global) rules present in the bundle consumer code.
@n370 @himself65 this change breaks such plugins as postcss-import, cause imported classes won't be modularized |
@Anidetrix yeah, you're right. We need to find a better solution. One easy solution I can think of is to maybe add a hardcoded list of plugin names that need to be loaded before postcss-modules and then split the user provided list of plugins into a list of plugins to be loaded before postcss-modules and a list to be loaded after. But really that's my naive take since I have just a small experience with the codebase. |
@n370 This is due to the fact that postcss-modules calls PostCSS inside itself, thus causing the doubling. The proper solution is to adapt separate PostCSS plugins for modules as it is done in webpack's css-loader. |
@Anidetrix I haven't observed that behavior in my use case but that might be the case. Anyways, I was thinking about why one would want to use the postcss-import plugin when they already have sass, less and stylus built in. |
@n370 probably with something like SugarSS |
got you! |
🎉 This issue has been resolved in version 2.4.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
The issue is still alive: |
Can confirm, I still see this issue on 3.1.8. When I use |
This particular issue is a dupe of #26. |
Hi,
I'm still investigating the issue but wanted some feedback:
Result:
I did some logging and the
postcss-custom-properties
is run twice on the same css module, hence the duplicate fallback.1st
2nd
The text was updated successfully, but these errors were encountered: