From 67298808cdc47f0466faa3c37f30bcd7f57b8f0f Mon Sep 17 00:00:00 2001 From: posrix Date: Wed, 11 Jul 2018 07:29:30 +0800 Subject: [PATCH] feat: pages support title option (#1619) * pages support title option * docs: pages `title` option --- docs/config/README.md | 7 +++++-- packages/@vue/cli-service/lib/config/app.js | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/config/README.md b/docs/config/README.md index fa3a56fd2f..b5b2f46dda 100644 --- a/docs/config/README.md +++ b/docs/config/README.md @@ -81,7 +81,7 @@ module.exports = { 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: - - An object that specifies its `entry`, `template` and `filename`; + - An object that specifies its `entry`, `template`, `filename` and `title`; - Or a string specifying its `entry`. ``` js @@ -93,7 +93,10 @@ module.exports = { // the source template template: 'public/index.html', // output as dist/index.html - filename: 'index.html' + filename: 'index.html', + // when using title option, + // template title tag needs to be <%= htmlWebpackPlugin.options.title %> + title: 'Index Page' }, // when using the entry-only string format, // template is inferred to be `public/subpage.html` diff --git a/packages/@vue/cli-service/lib/config/app.js b/packages/@vue/cli-service/lib/config/app.js index 4c2def1385..4641049b9b 100644 --- a/packages/@vue/cli-service/lib/config/app.js +++ b/packages/@vue/cli-service/lib/config/app.js @@ -115,6 +115,7 @@ module.exports = (api, options) => { pages.forEach(name => { const { + title, entry, template = `public/${name}.html`, filename = `${name}.html` @@ -126,7 +127,8 @@ module.exports = (api, options) => { const pageHtmlOptions = Object.assign({}, htmlOptions, { chunks: ['chunk-vendors', 'chunk-common', name], template: fs.existsSync(template) ? template : (fs.existsSync(htmlPath) ? htmlPath : defaultHtmlPath), - filename + filename, + title }) webpackConfig