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);
  }

 

上一篇:Webpack之Plugins


下一篇:【三维装箱】基于matlab求解三维装箱优化问题【含Matlab源码 949期】