webpack HtmlWebpackPlugin插件經常使用配置

webpack使用平常,使用webpack是須要壓縮html模板代碼請注意css

var HtmlWebpackPlugin = require('html-webpack-plugin')
    
webpackconfig = {
    ...
    plugins: [
        new HtmlWebpackPlugin({
        template: 'src/index.html',
        minify: {
            removeComments: true,
            collapseWhitespace: true,
            removeAttributeQuotes: true
      },
    }),
    ]
}

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

複製代碼

經常使用minify配置項html

removeComments 默認值false;是否去掉註釋
collapseWhitespace 默認值false;是否去掉空格
minifyJS 默認值false;是否壓縮html裏的js(使用uglify-js進行的壓縮)
minifyCSS 默認值false;是否壓縮html裏的css(使用clean-css進行的壓縮)
複製代碼

vue-lic3.0去掉eslint代碼校驗vue

lintOnSave: false
複製代碼
相關文章
相關標籤/搜索