tree shaking 被人们翻译成摇树优化
tree shaking 在webpack2中引入,在webpack4中默认配置
tree shaking 实际上是webpack 借鉴 rollup 的
rollup 也是一个javascript 的代码打包器
tree shaking 的作用是在打包的时候将没有用到的代码擦除掉,如下例子:
if(false)
{
console.log('这段代码永远不会执行')
}
//示例代码来自:https://www.fangbangxin.com/article/index/17078
tree shaking 在webpack中的配置:配置文件中的mode值为none的情况下为不进行tree shaking,如果mode为production则默认开启tree shaking