-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.babelrc.js
43 lines (42 loc) · 1.2 KB
/
.babelrc.js
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const pkg = require('./package.json')
const isBuildCommonjs = process.env.BABEL_ENV === "commonjs"
module.exports = {
"presets": [
[
"@babel/preset-env", {
// commonjs时: 需要构建commonjs模块
"modules": isBuildCommonjs ? "commonjs" : false,
targets: {
browsers: [
'last 2 versions',
'Firefox ESR',
'> 1%',
'ie >= 9',
'iOS >= 8',
'Android >= 4',
],
},
}
]
],
"plugins": [
"@babel/plugin-transform-member-expression-literals",
"@babel/plugin-transform-object-assign",
"@babel/plugin-transform-property-literals",
["@babel/plugin-transform-runtime", {
"helpers": true,
}],
"@babel/plugin-transform-spread",
"@babel/plugin-proposal-object-rest-spread",
["@babel/plugin-proposal-decorators", {
"legacy": true
}],
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-export-default-from",
// 构建commonjs时, 把版本好注入到js里, 作为固定好的变量
isBuildCommonjs && ["transform-define", {
"__VERSION__": pkg.version
}]
].filter(Boolean),
"exclude": "node_modules/**"
}