-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
PostCSS not applied to imports via composes
#10079
Comments
Vite puts postcss plugins in the following order. [postcssImport, postcssModules, ...userPlugins, postcssViteRewriteUrl] In this order ( ._component_8abi2_1 {
color: var(--color-red);
._nested_8abi2_7 {
width: 100%;
}
}
._foo_15itx_1 {
color: red;
} But when the order is ._component_8abi2_1 {
color: var(--color-red);
}._component_8abi2_1 ._nested_8abi2_7 {
width: 100%;
}._foo_15itx_1 {
color: red;
} So I think we need an option to apply a plugin before default ones, or reorders the plugins. |
We had a related PR to change the order of PostCSS plugins, and have the user ones before the internal ones: In that case, it was closed because the issue should have been fixed upstream. But it could count as another case where having the chance to inject plugins before Vite plugins could have been useful. Maybe we could have a |
I took a look around postcss plugin specs. Maybe it's possible to solve on plugins' side? https://github.com/postcss/postcss/releases/tag/8.0.0#:~:text=Plugins%20will%20re%2Dvisit%20changed%20nodes%20to%20reduce%20compatibility%20issues%20between%20plugins.%20Now%20the%20order%20of%20plugins%20in%20your%20PostCSS%20config%20will%20be%20less%20important. I feel it's better to avoid extending the plugin interface of PostCSS. |
Another point in favor of waiting here is that there is a chance we end up replacing PostCSS with LigthingCSS in the future |
Any news on when this will happen? I'm deciding if it's worth waithing for a fix to this issue or just go with plain old css :) |
The current approach with Precisely, now I can't compose a rule from another module and customize that rule with a custom media query at the same time. Is there any chance that the issue will be fixed somehow? |
@patak-dev LigthingCSS faster then PostCSS and probably LigthingCSS or CSSTree better for minifying and other tasks. It is unlikely that in the near future it will be possible to completely abandon PostCSS, while there is no support injecting plugins before except this
This isuue and #12336 will be relevant. |
I've implemented a fix via https://github.com/privatenumber/vite-css-modules (which is getting integrated into Vite core via #16018). Testing and feedback will be appreciated! |
Describe the bug
I'm trying to have styles included in a CSS module via
composes
processed by PostCSS, but it's not happening. All other styles are processed by PostCSS correctly.Take the following CSS modules and PostCSS config:
Expected result
I exect to see the styles I include with
.main
via `composes: component from "./component.module.css" to be valid (with PostCSS plugins applied). Expected result:Actual result
The styles included via
composes
are not processed by PostCSS. They are included in the<style>
tag as-is, resulting in invalid CSS.The same bug can be observed in the production build.
There was a similar issue logged and fixed in
vue-loader
: vuejs/vue-loader#959Reproduction
https://github.com/elisehein/vite-postcss-compose-repro
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: