-
Notifications
You must be signed in to change notification settings - Fork 1
/
babel.config.js
57 lines (45 loc) · 954 Bytes
/
babel.config.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
54
55
56
57
module.exports = function (api) {
const esm = api.env(['esm']);
api.cache(true);
const env = process.env.ENV;
const version = process.env.VERSION;
const envs = {
react: {
presets: [
'@babel/preset-react'
]
},
vue: {
plugins: [
'@vue/babel-plugin-jsx'
]
}
};
const presets = [
[
'@babel/preset-env',
{
browserslistEnv: process.env.BABEL_ENV || process.env.NODE_ENV,
modules: esm ? false : 'commonjs'
},
],
...(envs[env]?.presets || []),
'@babel/preset-typescript'
];
const other = {};
if (version === 'icons') {
other['sourceMaps'] = false;
other['minified'] = true;
}
const plugins = [
'@babel/plugin-transform-runtime',
'@babel/proposal-class-properties',
'@babel/proposal-object-rest-spread',
...(envs[env]?.plugins || [])
];
return {
presets,
plugins,
...other
};
};