chainWebpack 和 htmlWebpackPlugin搭配使用

const HtmlWebpackPlugin = require('html-webpack-plugin');


...

chainWebpack: config => {
    config
        .plugin('html')
            .use(HtmlWebpackPlugin)
            .tap(options  => {
                options.BASE_URL = 'sss'
                options.template = __dirname + '/public/index.html'
                options.title = 'sssssssssssss'
            return options
            })        
    }

注意看vue-cli3引用的html-webpack-plugin默认配置

 constructor (options) {
    // Default options
    this.options = _.extend({
      template: path.join(__dirname, 'default_index.ejs'),
      templateParameters: templateParametersGenerator,
      filename: 'index.html',
      hash: false,
      inject: true,
      compile: true,
      favicon: false,
      minify: false,
      cache: true,
      showErrors: true,
      chunks: 'all',
      excludeChunks: [],
      chunksSortMode: 'auto',
      meta: {},
      title: 'Webpack App',
      xhtml: false
    }, options);
  }

 

posted @ 2019-04-30 14:45  黑夜蓝天  阅读(6390)  评论(0编辑  收藏  举报