assets-webpack-plugin
assets-webpack-plugin copied to clipboard
Support chunk sorting options
It would be awesome to support sorting of the chunks, similar to https://github.com/jantimon/html-webpack-plugin/blob/master/lib/chunksorter.js
I currently use this plugin to create the assets and would like to automatically be able to include the appropriate script tags during SSR in the correct order automatically.
This could probably also supersede the manifestFirst option?
I think this would be a pretty major change as it would require the output to be wrapped in an array or some sortable structure instead of an object.
Not opposed to it, just would require some planning and a major release.
At worst, could a sort order index attribute be output as a property and leave the sorting up to the file consumer.
{
"runtime": {
"js": "runtime.913f0ed272c4b1c945f9.js",
"sortOrder": 0
},
"main": {
"js": "main.edc1ff76e4c8be6f4c81.js",
"sortOrder": 3
},
"polyfills": {
"js": "polyfills.ab67acf99a82d53b562f.js",
"sortOrder": 1
},
"styles": {
"css": "styles.03caaa68356691cce406.css",
"sortOrder": 0
},
"scripts": {
"js": "scripts.48544e4b8eb1ac0cceaa.js",
"sortOrder": 2
}
}
Yeah, that would be a good way to do it. Happy to review any PRs. A little too busy right now to do it myself.
What is the current order based on? It's not aplhabetical, it's not the same as the order reported by webpack in console (entry points, then chunks). Thanks.
There isn't any set order, outside of setting the manifestFirst
option. If you want to follow it through the code, you could probably start here: https://github.com/ztoben/assets-webpack-plugin/blob/master/lib/output/createOutputWriter.js#L59