-
Notifications
You must be signed in to change notification settings - Fork 1
/
babel.config.js
53 lines (48 loc) · 1.19 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
// define default preset list
const presets = [];
// define default plugin list
const plugins = [
'syntax-dynamic-import',
'syntax-jsx',
'transform-class-properties',
'transform-object-rest-spread',
['transform-react-jsx'],
'graphql-tag',
'import-graphql'
];
// define default babel options
const defaults = {
babelrc: false,
presets,
plugins
};
// define preset-env config for production
const presetEnvConfig = {
targets: {
browsers: ['> 5%']
},
modules: false
};
// group options by environment
const options = {
development: Object.assign({}, defaults),
production: Object.assign({}, defaults, {
presets: [
...(defaults.presets || []),
['babel-preset-env', presetEnvConfig]
],
plugins: [
...(defaults.plugins || []),
'transform-react-remove-prop-types',
[
'transform-runtime',
{
helpers: true,
polyfill: false, // polyfills will be handled by preset-env
regenerator: false
}
]
]
})
};
module.exports = env => options[env];