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
Modify 'import css' order more than 2 times, it will not work #406
Comments
this is because CssModule does not have 'libIdent' method. |
Please create minimum reproducible test repo, thanks |
Looks like problem in |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
node 12.3.1 result is right |
Please create minimum reproducible test repo |
Thanks looks like bug |
I think this was already fixed by webpack/webpack#8243 Could you try upgrading to the latest webpack version? |
No doesn't seem to be fixed |
Ok I found the issue. While the correct order is determined when emitting the asset, calculating the content hash is not done in with the correct order: mini-css-extract-plugin/src/index.js Lines 269 to 273 in 392c4ae
I was able to fix the problem after changing this to: const modules = Array.from(chunk.modulesIterable).filter(module => module.type === MODULE_TYPE);
const orderedModules = this.determineModulesInOrder(chunk, modules);
for (const m of orderedModules) {
if (m.type === MODULE_TYPE) {
m.updateHash(hash);
}
} I also extracted the following code snippet into a new function mini-css-extract-plugin/src/index.js Lines 454 to 555 in 392c4ae
To avoid emitting warnings in the hashing part I wrapped mini-css-extract-plugin/src/index.js Lines 534 to 543 in 392c4ae
in There are a bunch of other problems:
This doesn't work as well as expected for multiple reasons: The
In Chunks Modules are sorted by id, so this kind of affects the order. As hack we could use this instead: get id() {
return '';
}
set id(value) {} webpack 5 changes a lot of this stuff. I. e. there is no Send a PR |
mini-css-extract-plugin/src/index.js Lines 269 to 273 in 392c4ae
changing this to: const modules = Array.from(chunk.modulesIterable).filter(module => module.type === MODULE_TYPE);
modules.sort((a,b)=>{
return a.index-b.index;
})
for (const m of modules) {
if (m.type === MODULE_TYPE) {
m.updateHash(hash);
}
} |
Fixed for webpack v5 and v1.3.8 |
Expected Behavior
when I use webpack-dev-server. I modify css order. The out css should be modified at the same time.
For example:
out:
modify:
out:
Actual Behavior
Only the first modification works. Don't work from the second time.
For example:
out:
modify:
out:
modify:
out:
not change
How Do We Reproduce?
Modify import more than 2 times
The text was updated successfully, but these errors were encountered: