allow default vendors splitChunk setting to reuse existing chunks
this allows the user to specify chunk names
This commit is contained in:
parent
458a17bb39
commit
f48f82ed8f
|
@ -403,6 +403,7 @@ class WebpackOptionsDefaulter extends OptionsDefaulter {
|
|||
});
|
||||
this.set("optimization.splitChunks.cacheGroups.defaultVendors", {
|
||||
idHint: "vendors",
|
||||
reuseExistingChunk: true,
|
||||
test: NODE_MODULES_REGEXP,
|
||||
priority: -10
|
||||
});
|
||||
|
|
|
@ -3126,6 +3126,24 @@ chunk main.js (main) 147 bytes (javascript) 4.84 KiB (runtime) >{async-a}< >{asy
|
|||
+ 6 hidden root modules"
|
||||
`;
|
||||
|
||||
exports[`StatsTestCases should print correct stats for split-chunks-chunk-name 1`] = `
|
||||
"Entrypoint main = default/main.js
|
||||
chunk default/main.js (main) 192 bytes (javascript) 4.89 KiB (runtime) >{334}< >{709}< >{794}< [entry] [rendered]
|
||||
> ./ main
|
||||
./index.js 192 bytes [built]
|
||||
+ 6 hidden chunk modules
|
||||
chunk default/async-b.js (async-b) (id hint: vendors) 122 bytes <{179}> [rendered] reused as split chunk (cache group: defaultVendors)
|
||||
> b ./index.js 2:0-45
|
||||
./node_modules/b.js 122 bytes [built]
|
||||
chunk default/async-c-1.js (async-c-1) (id hint: vendors) 122 bytes <{179}> [rendered] reused as split chunk (cache group: defaultVendors)
|
||||
> c ./index.js 3:0-47
|
||||
> c ./index.js 4:0-47
|
||||
./node_modules/c.js 122 bytes [built]
|
||||
chunk default/async-a.js (async-a) 20 bytes <{179}> [rendered]
|
||||
> a ./index.js 1:0-45
|
||||
./node_modules/a.js 20 bytes [built]"
|
||||
`;
|
||||
|
||||
exports[`StatsTestCases should print correct stats for split-chunks-combinations 1`] = `
|
||||
"Entrypoint main = main.js
|
||||
chunk async-d.js (async-d) 101 bytes <{179}> [rendered]
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
import(/* webpackChunkName: "async-a" */ "a");
|
||||
import(/* webpackChunkName: "async-b" */ "b");
|
||||
import(/* webpackChunkName: "async-c-1" */ "c");
|
||||
import(/* webpackChunkName: "async-c-2" */ "c");
|
|
@ -0,0 +1 @@
|
|||
export default "a";
|
|
@ -0,0 +1,3 @@
|
|||
export default "b";
|
||||
// content content content content content content
|
||||
// content content content content content content
|
|
@ -0,0 +1,3 @@
|
|||
export default "c";
|
||||
// content content content content content content
|
||||
// content content content content content content
|
|
@ -0,0 +1,27 @@
|
|||
const stats = {
|
||||
hash: false,
|
||||
timings: false,
|
||||
builtAt: false,
|
||||
assets: false,
|
||||
chunks: true,
|
||||
chunkRelations: true,
|
||||
chunkModules: true,
|
||||
chunkOrigins: true,
|
||||
entrypoints: true,
|
||||
modules: false
|
||||
};
|
||||
module.exports = {
|
||||
mode: "production",
|
||||
entry: {
|
||||
main: "./"
|
||||
},
|
||||
output: {
|
||||
filename: "default/[name].js"
|
||||
},
|
||||
optimization: {
|
||||
splitChunks: {
|
||||
minSize: 100
|
||||
}
|
||||
},
|
||||
stats
|
||||
};
|
Loading…
Reference in New Issue