where to find or how to set htmlWebpackPlugin.options.title in project created with vue cli 3?

mayank1513 picture mayank1513 · May 26, 2020 · Viewed 11.7k times · Source

I wanted to set title to my webpage created with vue cli 3 and thus looked into public/index.html. There, I found <title><%= htmlWebpackPlugin.options.title %></title>.

How do I set and modify htmlWebpackPlugin.options.title in vue cli 3 project?

Answer

Lucio M. Tato picture Lucio M. Tato · Aug 15, 2020

create a file vue.config.js at the root

//vue.config.js
module.exports = {
    chainWebpack: config => {
        config
            .plugin('html')
            .tap(args => {
                args[0].title = "My Vue App";
                return args;
            })
    }
}

see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-plugin