forked from react-bootstrap/react-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.babelrc.js
53 lines (51 loc) · 1.28 KB
/
.babelrc.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
module.exports = api => {
let dev = false;
let modules = true;
switch (api.env()) {
case 'docs':
case 'test':
dev = true;
modules = false;
break;
case 'dist-dev':
dev = true;
modules = false;
break;
case 'dist-prod':
case 'esm':
modules = false;
break;
case 'build':
default:
break;
}
return {
presets: [
[
'@babel/preset-env',
{
loose: true,
shippedProposals: true,
modules: modules ? 'commonjs' : false,
targets: {
browsers: ['last 4 versions', 'not ie <= 8'],
},
},
],
['@babel/preset-react', { development: dev }],
],
plugins: [
['@babel/plugin-proposal-class-properties', { loose: true }],
'@babel/plugin-proposal-export-default-from',
'@babel/plugin-proposal-export-namespace-from',
['@babel/plugin-transform-runtime', { useESModules: !modules }],
'babel-plugin-dev-expression',
modules && 'babel-plugin-add-module-exports',
api.env() === 'test' && 'babel-plugin-istanbul',
!dev && [
'transform-react-remove-prop-types',
{ removeImport: true, additionalLibraries: ['prop-types-extra'] },
],
].filter(Boolean),
};
};