-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Incorrect css order with @import #1391
Comments
Note that I get the correct order when bundled with rollup using rollup-plugin-postcss |
Here's my attempt to reproduce this:
However, I can't reproduce the problem. Here's what I get: @import "http://internet-url-1";
@import "http://internet-url-2";
/* relative-path-1.css */
.relative-path-1 {
color: green;
}
/* relative-path-2.css */
.relative-path-2 {
color: blue;
}
/* some.css */
/* other.css */
.other.css {
color: red;
} In this case
That's not necessarily how CSS imports work. CSS import order is inherently different than JS import order, which could be why you're seeing this. In CSS, That means if multiple files import the same shared dependency and then override it in various ways, only the last file to do so will override anything. This is inconvenient but is how CSS actually works (i.e. in the browser). The behavior of
PostCSS actually gets CSS import order wrong in some cases. So the behavior you're seeing from Rollup isn't necessarily correct. The incorrect behavior was introduced here: postcss/postcss-import#211. That change made CSS import order identical to JS import order. While that's convenient, it's also incorrect. You can configure PostCSS to use the correct CSS import order by using |
Seems like this is fixed in 0.12.6 via #1342 . I was using 0.12.5. |
I have a .tsx file that looks like
The 'some.css' file is something like
I was expecting the final bundled css to be
However, I am noticing the following order
This is problematic for me as the css included from the js code should supersede the other css in case of a conflict.
The text was updated successfully, but these errors were encountered: