Vue-Cli: 'title' option for htmlWebpackPlugin does not work

According to the configuration reference of the Vue CLI, you could set the title by overriding the pages section in vue.config.js. Since all config options are optional except for entry, this should do it:

module.exports = {
  pages: {
    index: {
      entry: 'src/index/main.js',
      title: 'Custom Title'
    }
  }
}

I submitted a bug report as recommended by @tony19.

tldnr: Edit the title in the template at public/index.html which will be used at build time.

Long version: I did not have the public/index.html anymore in my project, apparently I deleted it some time ago and therefore never used the template functionality. The cli still used a template located somewhere and therefore all changes for the htmlWebpackPlugin do nothing.

So either you disable the index.html-template and modify the htmlWebpackPlugin or you edit the template to make your changes.


To set the title of a vue-cli application you can set the title in HtmlWebpackPlugin (just as you have)

/* vue.config.js */
chainWebpack: (config) => {
    config
      .plugin('html')
      .tap((args) => {
        args[0].title = 'Custom Title';
        return args;
      });
  },

then you must edit the <title> of public/index.html to reference the title using lodash syntax.

<!-- public/index.html -->
<head>
  <title><%= htmlWebpackPlugin.options.title %></title>
</head>

Check out Html Webpack Plugin's documentation on writing your own templates!

Hope this helps!


Unfortunately the above answers didn't help me. As stated in the offical documentation you only need to add the vue.config.js to your root folder and add the following:

    // vue.config.js
    module.exports = {
      chainWebpack: config => {
        config
        .plugin('html')
        .tap(args => {
          args[0].title = 'Your new title'
          return args
        })
      }
    }

Keep in mind that you have to stop the App and start again with npm run serve. This worked for me.