Note: this question about chunks, not output bundles.
If we need to distribute webpack
output bundles between multiple subpaths, we can do it next way (unusual, but I use absolute paths):
const WEBPACK_CONFIG = {
// ...
entry: {
'open/js/testOpenEntryPoint': 'C:/.../example.loc/source/open/3_es6/testOpenEntryPoint',
'admin/js/testAdminEntryPoint': 'C:/.../example.loc/source/admin/3_es6/testAdminEntryPoint'
},
output: {
path: 'dest',
filename: '[name].js',
chunkFilename: '[name].js'
}
}
However, it does not work for chunks: chunkFilename
, unlike filename
, ignores subpath and outputs chunks in single directory. Nevertheless, can we distribute chunks between multiple subpaths as shown below?
Currently I know only multi-compilation solution, but maybe it is more simple way.
source
open
testOpenEntryPoint.js
dyn_load
dynForTestOpenEntryPoint.js
admin
testOpenEntryPoint.js
dyn_load
dynForTestAdminEntryPoint.js
dist
open
testOpenEntryPoint.js
dyn_load
0.js
admin
testOpenEntryPoint.js
dyn_load
1.js