html 和 js 压缩
2021-02-10 14:15
阅读:644
YPE html>
标签:mic mod out comm mini 自动 res hit product
1,js 压缩:
将 mode 改为“production" 即可,production 模式下,webpack 会自动压缩 js 文件
2,html 压缩:
src / index.html
webpack hello webpack
webpack配置:
const {resolve} = require(‘path‘)
const HtmlWebpackPlugin = require(‘html-webpack-plugin‘)
module.exports={
entry:‘./src/index.js‘,
output:{
filename:‘bundle.js‘,
path:resolve(__dirname,‘build‘)
},
plugins:[
new HtmlWebpackPlugin({
template:‘./src/index.html‘,
minify:{
collapseWhitespace:true, //移除空格
removeComments:true //移除注释
}
})
],
mode:‘development‘
}
打包后的 index.html,清除了空格和注释,
![]()
html 和 js 压缩
标签:mic mod out comm mini 自动 res hit product
原文地址:https://www.cnblogs.com/shanlu0000/p/13052150.html
评论
亲,登录后才可以留言!