0%

JavaScript compiler: Babel

资源

.babelrc

babel

安装

1
npm i -D @babel/core @babel/preset-env @babel/cli

.babelrc

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
"env": {
"production": {
"presets": [
[
"@babel/preset-env",
{
"modules": false
}
]
]
}
},
"ignore": [
"node_modules/**"
]
}

安装 cross-env

1
npm i -D cross-env

package.json

1
2
3
4
5
6
{
"scripts": {
"build": "rollup --config",
"build:prod": "cross-env BABEL_ENV=production npm run build"
}
}

Polyfill: core-js

安装

1
npm i -D core-js@3

.babelrc

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{
"env": {
"production": {
"presets": [
[
"@babel/preset-env",
{
"modules": false,
"useBuiltIns": "usage",
"corejs": {
"version": 3,
"proposals": true
}
}
]
]
}
}
}

babel-jest