-
Notifications
You must be signed in to change notification settings - Fork 10
/
_babel.config.js
86 lines (80 loc) · 2.54 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/**
* @param selectMode {SelectMode}
* @param selectTarget {SelectTarget}
* @returns {*}
*/
module.exports.configureBabel = (selectMode, selectTarget) => {
const presetEnvConfig = selectTarget({
legacy: {
modules: false,
useBuiltIns: 'entry',
corejs: '3',
targets: {
browsers: ['> 1%', 'last 2 versions', 'Firefox ESR'],
},
},
modern: {
modules: false,
useBuiltIns: 'entry',
corejs: '3',
targets: {
browsers: [
'last 2 Chrome versions',
'not Chrome < 60',
'last 2 Safari versions',
'not Safari < 10.1',
'last 2 iOS versions',
'not iOS < 10.3',
'last 2 Firefox versions',
'not Firefox < 54',
'last 2 Edge versions',
'not Edge < 15',
],
},
},
});
const presets = ['@babel/preset-react', '@babel/typescript', ['@babel/preset-env', presetEnvConfig]];
// define default plugin list
const plugins = [
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-syntax-jsx',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-transform-modules-commonjs',
'@babel/plugin-transform-react-jsx',
"@babel/plugin-transform-runtime",
'graphql-tag',
'import-graphql',
];
// define default babel options
const defaults = {
babelrc: false,
presets,
plugins,
};
const options = {
development: Object.assign({}, defaults, {
presets: defaults.presets,
plugins: defaults.plugins,
}),
production: Object.assign({}, defaults, {
presets: defaults.presets,
plugins: [
...defaults.plugins,
selectTarget({ modern: 'transform-react-remove-prop-types' }),
selectTarget({
modern: [
'@babel/plugin-transform-runtime',
{
corejs: true,
helpers: true,
regenerator: true,
useESModules: false,
},
],
}),
].filter(Boolean),
}),
};
return selectMode(options);
};