-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbabel.config.js
52 lines (43 loc) · 1.34 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
/* eslint global-require: off */
const developmentEnvironments = ['development', 'test'];
const developmentPlugins = [require('react-hot-loader/babel')];
const plugins = [
require('@loadable/babel-plugin'),
require('@babel/plugin-transform-runtime'),
[require('@babel/plugin-proposal-decorators'), { legacy: true }],
require('@babel/plugin-proposal-export-default-from'),
require('@babel/plugin-proposal-class-properties'),
require('@babel/plugin-proposal-object-rest-spread'),
require('@babel/plugin-transform-async-to-generator'),
require('@babel/plugin-syntax-dynamic-import')
];
const cssModules = (test = false) => [
'react-css-modules',
{
filetypes: {
'.scss': {
syntax: 'postcss-scss',
plugins: ['postcss-nested']
}
},
generateScopedName: test ? '[local]' : '[name]__[local]__[hash:base64:5]',
webpackHotModuleReloading: true,
autoResolveMultipleImports: true
}
];
module.exports = api => {
const development = api.env(developmentEnvironments);
const test = api.env(['test']);
return {
presets: [
[require('@babel/preset-env'), { targets: 'last 2 versions, ie 11' }],
require('@babel/preset-react'),
require('@babel/preset-flow')
],
plugins: [
...plugins,
cssModules(test),
...(development ? developmentPlugins : [])
]
};
};