Skip to content

Commit 4db901c

Browse files
committed
fix: fine tune chunk splitting
close #1488
1 parent 12d51fd commit 4db901c

File tree

1 file changed

+10
-5
lines changed
  • packages/@vue/cli-service/lib/config

1 file changed

+10
-5
lines changed

packages/@vue/cli-service/lib/config/app.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,14 @@ module.exports = (api, options) => {
8484
webpackConfig.entryPoints.clear()
8585

8686
const pages = Object.keys(multiPageConfig)
87+
const normalizePageConfig = c => typeof c === 'string' ? { entry: c } : c
8788

8889
pages.forEach(name => {
8990
const {
9091
entry,
9192
template = `public/${name}.html`,
9293
filename = `${name}.html`
93-
} = multiPageConfig[name]
94+
} = normalizePageConfig(multiPageConfig[name])
9495
// inject entry
9596
webpackConfig.entry(name).add(api.resolve(entry))
9697

@@ -107,7 +108,9 @@ module.exports = (api, options) => {
107108
})
108109

109110
pages.forEach(name => {
110-
const { filename = `${name}.html` } = multiPageConfig[name]
111+
const {
112+
filename = `${name}.html`
113+
} = normalizePageConfig(multiPageConfig[name])
111114
webpackConfig
112115
.plugin(`preload-${name}`)
113116
.use(PreloadPlugin, [{
@@ -148,16 +151,18 @@ module.exports = (api, options) => {
148151
if (isProd) {
149152
webpackConfig
150153
.optimization.splitChunks({
151-
chunks: 'all',
152-
name: (m, chunks, cacheGroup) => `chunk-${cacheGroup}`,
153154
cacheGroups: {
154155
vendors: {
156+
name: 'chunk-vendors',
155157
test: /[\\/]node_modules[\\/]/,
156-
priority: -10
158+
priority: -10,
159+
chunks: 'initial'
157160
},
158161
common: {
162+
name: 'chunk-common',
159163
minChunks: 2,
160164
priority: -20,
165+
chunks: 'initial',
161166
reuseExistingChunk: true
162167
}
163168
}

0 commit comments

Comments
 (0)