forked from AndrewRedican/react-json-editor-ajrm
-
Notifications
You must be signed in to change notification settings - Fork 1
/
babel.config.js
55 lines (50 loc) · 1.35 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
const { BABEL_ENV } = process.env;
console.log("Running Babel ...", { BABEL_ENV });
const moduleSystem = (BABEL_ENV && BABEL_ENV.startsWith('modules:')) ? BABEL_ENV.substring("modules:".length) : "es";
// For the ES configuration only transpile react to valid JavaScript.
// For commonjs transpile to old JS versions.
const presets = moduleSystem === "es"
? ['@babel/preset-react']
: [
['@babel/preset-env', {
targets: {
ie: 11,
edge: 14,
firefox: 45,
chrome: 49,
safari: 10,
node: '6.11',
},
modules: moduleSystem,
}],
'@babel/preset-react'
];
// The ES system does not polyfill etc, while the others do.
const transformOptions = moduleSystem === "es"
? {
helpers: true,
useESModules: true
}
: {
helpers: true,
useESModules: false
};
module.exports = {
presets,
plugins: [
'@babel/plugin-transform-object-assign',
'@babel/plugin-proposal-object-rest-spread',
'babel-plugin-extensible-destructuring',
['@babel/plugin-transform-runtime', transformOptions]
],
env: {
production: {
plugins: [
// Optimize constant react elements in the production build. (Makes debugging harder, so skip this in development)
'transform-react-constant-elements',
],
ignore: ['test/*']
}
},
ignore: ['scripts/*.js']
};