Skip to content

Commit 8415622

Browse files
committed
feat(build): allow specifying chunks in multi-page mode
close vuejs#1923
1 parent a3596a1 commit 8415622

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

docs/config/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ module.exports = {
8383

8484
Build the app in multi-page mode. Each "page" should have a corresponding JavaScript entry file. The value should be an object where the key is the name of the entry, and the value is either:
8585

86-
- An object that specifies its `entry`, `template`, `filename` and `title`;
86+
- An object that specifies its `entry`, `template`, `filename`, `title` and `chunks` (all optional except `entry`);
8787
- Or a string specifying its `entry`.
8888

8989
``` js
@@ -98,7 +98,10 @@ module.exports = {
9898
filename: 'index.html',
9999
// when using title option,
100100
// template title tag needs to be <title><%= htmlWebpackPlugin.options.title %></title>
101-
title: 'Index Page'
101+
title: 'Index Page',
102+
// chunks to include on this page, by default includes
103+
// extracted common chunks and vendor chunks.
104+
chunks: ['chunk-vendors', 'chunk-common', 'index']
102105
},
103106
// when using the entry-only string format,
104107
// template is inferred to be `public/subpage.html`

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,15 @@ module.exports = (api, options) => {
120120
title,
121121
entry,
122122
template = `public/${name}.html`,
123-
filename = `${name}.html`
123+
filename = `${name}.html`,
124+
chunks
124125
} = normalizePageConfig(multiPageConfig[name])
125126
// inject entry
126127
webpackConfig.entry(name).add(api.resolve(entry))
127128

128129
// inject html plugin for the page
129130
const pageHtmlOptions = Object.assign({}, htmlOptions, {
130-
chunks: ['chunk-vendors', 'chunk-common', name],
131+
chunks: chunks || ['chunk-vendors', 'chunk-common', name],
131132
template: fs.existsSync(template) ? template : (fs.existsSync(htmlPath) ? htmlPath : defaultHtmlPath),
132133
filename,
133134
title

0 commit comments

Comments
 (0)