Skip to content

HTML

设置 title

默认标题是通过 html-webpack-plugin 插件来控制的,如下:

html
<title><%= htmlWebpackPlugin.options.title %></title>
  1. 通过 pages 字段:

    js
    module.exports = {
      pages: {
        index: {
          entry: 'src/main.js', // 入口文件
          title: '你的标题',
        },
      },
    }
  2. 通过 chainWebpack 直接修改 webpack 配置:

    js
    module.exports = {
      chainWebpack: config => {
        config.plugin('html').tap(args => {
          args[0].title = '你的标题'
          return args
        })
      },
    }

基于 MIT 许可发布