-
-
Notifications
You must be signed in to change notification settings - Fork 384
fix(index): correct order of CSS imports #242
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test case missing
I assume this happens when chunks are shared between multiple chunk groups. This can happen when using |
@sokra Yes, you're right. Thats when it happens. I'm not so familiar with Webpack and groupsIterable, but will try to dig into it. |
@@ -390,7 +398,11 @@ class MiniCssExtractPlugin { | |||
const [chunkGroup] = chunk.groupsIterable; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here only the first chunkGroup is used. Maybe this need to be reconsidered. See also comment above.
@sokra : I have created a test case: https://github.com/jarandmi/scss-order-bug The order the style chunks is return is:
I think the problem has too do with sass, and the `@import "../variables";`` The order will also be different in develop and production build. And none of them seem right. My suggestion is to make a sort function that order them in the correct way.
|
It will also be fixed if i sort by module.id, instead of
|
Hi there, dropping in to say we're experiencing this problem as well. Fixing the comparator function to sort That being said, I think there's a bigger problem to consider: when sharing CSS between multiple chunk groups, we don't know for sure what the correct order is. Consider the original problem (#130): a.js
b.js
If we want to share CSS between these two chunks, we have to decide how to order I'm not sure what the proper solution is. It seems to me that the current configuration doesn't provide enough information to correctly judge what CSS order is correct — at least in the case where it's shared across multiple chunks. The remedy might be more configuration, making a "best guess", or handing off the responsibility to the user:
Personally I'm in favor of the latter as this solves our use case but I'd be interested to hear your thoughts on this @jarandmi @sokra. Happy to work on an implementation too. For now we've forked the plugin to revert to the old sort method (ie. using |
Could you check if #246 fixes your problem? |
This PR contains a:
Motivation / Use-Case
Modules with undefined ID will now be sorted to the bottom of array, and imported after the once with and ID
Breaking Changes
Additional Info