-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
babel.config.js
68 lines (64 loc) · 1.52 KB
/
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
58
59
60
61
62
63
64
65
66
67
68
module.exports = (api) => {
const env = api.env();
const envOptions = {
debug: false,
modules: false,
useBuiltIns: 'usage',
corejs: '3.15',
};
const config = {
presets: [
'@babel/react',
'@babel/typescript',
['@babel/env', envOptions],
],
plugins: [
'@babel/syntax-dynamic-import',
['@babel/proposal-object-rest-spread', { useBuiltIns: true }],
['@babel/proposal-decorators', { legacy: true }],
'@babel/proposal-class-properties',
['react-intl', { messagesDir: './build/messages/' }],
'preval',
],
'sourceType': 'unambiguous',
};
switch (env) {
case 'production':
config.plugins.push(...[
'lodash',
[
'transform-react-remove-prop-types',
{
mode: 'remove',
removeImport: true,
additionalLibraries: [
'react-immutable-proptypes',
],
},
],
'@babel/transform-react-inline-elements',
[
'@babel/transform-runtime',
{
helpers: true,
regenerator: false,
useESModules: true,
},
],
]);
break;
case 'development':
config.plugins.push(...[
'@babel/transform-react-jsx-source',
'@babel/transform-react-jsx-self',
]);
break;
case 'test':
config.plugins.push(...[
'transform-require-context',
]);
envOptions.modules = 'commonjs';
break;
}
return config;
};