Skip to content

Commit 6729880

Browse files
posrixAkryum
authored andcommitted
feat: pages support title option (vuejs#1619)
* pages support title option * docs: pages `title` option
1 parent 62e2868 commit 6729880

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

docs/config/README.md

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

8282
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:
8383

84-
- An object that specifies its `entry`, `template` and `filename`;
84+
- An object that specifies its `entry`, `template`, `filename` and `title`;
8585
- Or a string specifying its `entry`.
8686

8787
``` js
@@ -93,7 +93,10 @@ module.exports = {
9393
// the source template
9494
template: 'public/index.html',
9595
// output as dist/index.html
96-
filename: 'index.html'
96+
filename: 'index.html',
97+
// when using title option,
98+
// template title tag needs to be <title><%= htmlWebpackPlugin.options.title %></title>
99+
title: 'Index Page'
97100
},
98101
// when using the entry-only string format,
99102
// template is inferred to be `public/subpage.html`

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ module.exports = (api, options) => {
115115

116116
pages.forEach(name => {
117117
const {
118+
title,
118119
entry,
119120
template = `public/${name}.html`,
120121
filename = `${name}.html`
@@ -126,7 +127,8 @@ module.exports = (api, options) => {
126127
const pageHtmlOptions = Object.assign({}, htmlOptions, {
127128
chunks: ['chunk-vendors', 'chunk-common', name],
128129
template: fs.existsSync(template) ? template : (fs.existsSync(htmlPath) ? htmlPath : defaultHtmlPath),
129-
filename
130+
filename,
131+
title
130132
})
131133

132134
webpackConfig

0 commit comments

Comments
 (0)