Skip to content

Commit

Permalink
feat: pages support title option (#1619)
Browse files Browse the repository at this point in the history
* pages support title option

* docs: pages `title` option
  • Loading branch information
posrix authored and Akryum committed Jul 10, 2018
1 parent 62e2868 commit 6729880
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions docs/config/README.md
Expand Up @@ -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
Expand All @@ -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 <title><%= htmlWebpackPlugin.options.title %></title>
title: 'Index Page'
},
// when using the entry-only string format,
// template is inferred to be `public/subpage.html`
Expand Down
4 changes: 3 additions & 1 deletion packages/@vue/cli-service/lib/config/app.js
Expand Up @@ -115,6 +115,7 @@ module.exports = (api, options) => {

pages.forEach(name => {
const {
title,
entry,
template = `public/${name}.html`,
filename = `${name}.html`
Expand All @@ -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
Expand Down

0 comments on commit 6729880

Please sign in to comment.