-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.babelrc
29 lines (29 loc) · 1.11 KB
/
.babelrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
https://juejin.cn/post/7062180864968359943
tree-shaking的主要作用是用来清除代码中无用的部分。
目前在webpack4 我们设置mode为production的时候已经自动开启了tree-shaking。
但是要想使其生效,生成的代码必须是ES6模块。不能使用其它类型的模块如CommonJS之流。
如果使用Babel的话,这里有一个小问题,因为Babel的预案(preset)默认会将任何模块类型都转译成CommonJS类型,这样会导致tree-shaking失效。
修正这个问题也很简单,在.babelrc文件或在webpack.config.js文件中设置modules: false就好了
*/
{
"presets": [
[
"@babel/preset-env",
{
"modules": false,
"useBuiltIns":"usage",
"corejs": "3" // 声明corejs版本
}
]
],
// antd-mobile按需加载
"plugins": [
[
"import",
{
"libraryName": "antd-mobile", "style": "css"
}
] // `style: true` 会加载 less 文件
]
}