-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
Wrong chunks order also with chunksSortMode: 'none' #481
Comments
I am also facing the same issue, and described the problem in details here. |
I used chunksSortMode with custom function and it worked for me as a trick (alphabetical order)
|
Yes. Custom functions are working, but not the other values. |
This can only be a simple choice if it is positive or reverse. |
|
The problem is not that these functions aren't intuitive. |
Feel free to contribute :) |
'function', in alphabetical order, because the sort method is called internally. |
Yes, sorry. |
@Ks89 'function', in alphabetical order, because the sort method is called internally. |
Sorry @humorHan I really don't understand what you are trying to say |
@jantimon
By looking at the source code to understand, it is possible because the source code inside the sort function, the loss of the flexibility of the parameters. |
You can pass a function which is in full control of sorting your assets. Didn't that work for you? |
@jantimon
|
Haha no no that's fine. Please read here how to write a comparison method: |
I did something like this to customize my chunk ordering. Basically, it will order the chunk the way you put the chunks in the array.
|
Finally, I created a skeleton project, as promised: https://github.com/Ks89/Angular2-webpack2-skeleton Branches:
run |
@jamesjieye
|
Yes, by specifying the order like this:
BTW, if you want to exlcude |
@jamesjieye ok! thank you~ |
@jamesjieye's custom function above works very nicely. If we step back and look at the root issue, I'm thinking the better solution is to design webpack such that the entry property can accept either an object or an array. The fact that we have to cobble together something to control order seems kind of silly to me. |
yes! a sensible default ordering should be the array order. |
@bholben totally agree! When I wanted to order the chunks, I was thinking passing an array to define the order. It would be much easier to use if the custom order function was built into the plugin itself. |
@jamesjieye yes,I also agree that once I tried to change the plug-in source code, can be sorted in accordance with the order of the incoming array, I feel more convenient |
Thanks to @jamesjieye
ugly but works. i spent awhile trying to figure out |
Tks @jamesjieye && @anthonyettinger, these are my settings for define resource sorting: new HtmlWebpackPlugin({
title: 'App Name',
minify: {
collapseWhitespace: true,
keepClosingSlash: true,
removeComments: true
},
chunksSortMode: (c1, c2) => {
// Corrige bug da ordenação de assets.
let orders = ['common', 'vendor', 'app'];
let o1 = orders.indexOf(c1.names[0]);
let o2 = orders.indexOf(c2.names[0]);
return o1 - o2;
},
filename: '../index.html',
favicon: './src/assets/images/favicon.ico',
template: './src/assets/index.ejs'
}) |
@kamihouse Can you show me your configuration information? thanks! |
One more way to do this:
Only real difference here is that the order is defined in the same place as the sorter, so you can't forget to update both locations when you add a new chunk... |
Would it make sense to add a new options (e.g. called |
Just ran into this issue myself. Would be nice to have the order of the |
Same issue over here. Would be nice a manual option that just adds them as the names are added in the array. |
Well, I am new to the opensource community, not really know how to add something from myself, but
Voila! This way you switched to the Hope this helps somebody! |
An option to define the chunk order manually would be really great! |
Merged in #684 |
Released 2.30.0 |
why i use chunksSortMode: manual or i write a function, all two no worker. and my version is the lastest. help ??? |
In case you rather to set the order manually instead of creating a function and as per html-webpack-plugin 2.30.1 version. Setting chunksSortMode to 'manual' loads the chunks in the same order than in the chunks option. // The following code will include vendor and app chunks in that particular order.
chunks: ['vendor', 'app'],
chunksSortMode: 'manual', |
When I met this problem, I gave the official feedback on why there was no attribute value of'manual', which would be more convenient. But when I saw the new version of the problem, I was very happy, at least to accept the proposal |
@Javierb is it just me or does your snippet not have any effect on the order of: // Both are ordered as ['app', 'vendor', 'manifest']
compilation.getStats().toJson().chunks;
compilation.getStats().toJson().assetsByChunkName; I am using: new HtmlWebpackPlugin({
inject: true,
template: './index.html',
chunks: ['manifest', 'vendor', 'app'], // doesn't seem to do anything?
chunksSortMode: 'manual', // doesn't seem to do anything?
...
}); ?? |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I want to create two html pages based on ejs templates, injecting chunks into the body tag.
Pages are created and everything seems to be ok, but the order of chunks is wrong.
If I use chunksSortMode:'auto' for both files -> the first is ok (polyfills->vendor->app), but the second one no (admin->polyfills->vendor)
If I use chunksSortMode:'none' for both files -> both of them are wrong. The first one is (vendor->app->polyfills), the second one (vendor->admin->polyfills)
For the first file (with app) I can use 'auto', but for the second one, I'm obliged to create a crazy-custom-order function [p..-v...-a... (not alphabetical order)] (that i don't want to post here, because it's something the no one should see :( ).
The expected behaviour should be this:
Every other behaviour with chunksSortMode: 'none' it is weird.
PS: I created my chunks in this way (probably, the cause of this issue is here...I really don't know):
I used: Nodejs 7.0.0, macOS Sierra, Webpack 2.1.0 beta 25, HtmlWebpackPlugin: 2.24.1
Thank u,
Ks89
The text was updated successfully, but these errors were encountered: