-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.babelrc.js
53 lines (45 loc) Β· 1.15 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
44
45
46
47
48
49
50
51
52
53
const domprops = require('babel-plugin-minify-mangle-properties/domprops.json')
const plugins = [['babel-plugin-module-resolver', { alias: { '~': './src' } }]]
const presets = ['@babel/preset-flow']
if (process.env.NODE_ENV === 'production') {
presets.push('@babel/preset-env')
}
if (process.env.NODE_ENV === 'mangle-properties') {
presets.length = 0
plugins.length = 0
const whitelist = [
//
'navigation',
'rotation',
'position',
'command',
'target',
'update',
'type',
]
const blacklist = [
//
]
const reservedNames = [...blacklist, ...domprops.props].filter(
x => !whitelist.includes(x)
)
plugins.push(['babel-plugin-minify-mangle-properties', { reservedNames }])
}
if (process.env.NODE_ENV === 'minify') {
presets.length = 0
plugins.length = 0
presets.push([
'babel-preset-minify',
{
mangle: {
topLevel: true,
},
keepClassName: false,
keepFnName: false,
},
])
}
if (process.env.NODE_ENV === 'test') {
plugins.push('@babel/plugin-transform-modules-commonjs')
}
module.exports = { plugins, presets }