webpack 基础 - 13 ( tree-shaking 去除无用的代码)
作者:互联网
tree shaking 去除无用的代码
1、前提:ES6的模块化,开启production环境
减少代码体积
module.exports = {
...
mode:'production',
}
2、添加package.json配置
可能对css有影响
"sideEffects": ["*.css","*.scss"]
{
...
"sideEffects": [
"*.css",
"*.scss"
]
}
标签:scss,...,13,sideEffects,tree,webpack,production,css 来源: https://blog.csdn.net/Janicecat/article/details/121915329