webpack5 在生产环境下,js/html 代码自动压缩
webpack4 下,生产环境 js 代码也会自动压缩
html
采用 HtmlWebpackPlugin
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
plugins: [
new HtmlWebpackPlugin({
// 移除空格
collapseWhitespace: true,
// 移除注释
removeComments: true
})
],
mode: 'production'
}