webpack使用日常,使用webpack是需要压缩html模板代码请注意
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配置项
removeComments 默认值false;是否去掉注释
collapseWhitespace 默认值false;是否去掉空格
minifyJS 默认值false;是否压缩html里的js(使用uglify-js进行的压缩)
minifyCSS 默认值false;是否压缩html里的css(使用clean-css进行的压缩)
复制代码
vue-lic3.0去掉eslint代码校验
lintOnSave: false
复制代码