-
Notifications
You must be signed in to change notification settings - Fork 0
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-assign-layer usage in Vite #10
Comments
Can you give an example of when this situation might occur? I would suggest that normally if you're mixing CSS into a component, it should be at a separate layer, with either a higher or lower priority in the stack. |
Hey @IanVS , thanks for the reply. Text component has some styling like text color. ErrorText uses text component and also override the text color property to other color via classname prop: ErrorMessage Now ideally ErrorText property should take the precedence as we have mentioned the error text style class in the end. But in Vite the order gets changed. There are many other such cases in our app. Also there is one more query: import textStyles from '../Text/Text.module.css'; |
This works fine as long as you're not using code splitting / lazy loading in your app. If you are, then you'll likely hit the Vite issue. Another way you could solve this would be to ensure that Another thing we have done, if we have common patterns that we want to re-use across different components, is to create a layer for I haven't tried it myself, but you could also try setting a higher-priority layer like FWIW, here's our base-css file, to give an idea of how it could be structured: /* establish a layer order up-front, from lowest to highest priority */
@layer defaults, theme, libraries, patterns, components, utilities, overrides;
/** Defaults */
@import url('defaults.css');
/** Theme */
@import url('theme/colors.css');
@import url('theme/typography.css');
/** Patterns */
@import url('../../components/atoms/forms/border-focusable.css');
@import url('../../components/patterns/menus/menu.css');
/** Components are assigned by a PostCSS plugin for all `*.module.css` files */
/** Utilities */
@import url('utilities/layout.css');
@import url('utilities/color.css');
@import url('utilities/borders.css');
@import url('utilities/typography.css'); |
Thanks @IanVS for the detailed explanation. Yeah we want to use css code split. After that only we face this issue. We will try to structure our styles in different layer so that we can set the priority accordingly. |
Hello
This is in with reference to issue: vitejs/vite#3924
As mentioned, we can use this plugin to avoid the css module order issue.
So to solve this, how to give preference order with same component layer
Lets say there are 2 module.css in same component layer and there orders seems to be incorrect sue to vite issue.
how we can define the preference order using this plugin?
Thanks for the help!
The text was updated successfully, but these errors were encountered: