forked from zengm-games/zengm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbabel.config.js
54 lines (49 loc) · 1.46 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
// Need this rather than .babelrc to run on d3 inside node_modules (see also rollup-plugin-babel config)
module.exports = api => {
// Make sure config gets updated when process.env.LEGACY changes
api.cache.invalidate(() =>
JSON.stringify([process.env.LEGACY, process.env.NODE_ENV]),
);
const plugins = [require("./tools/babel-plugin-sport-functions")];
if (process.env.LEGACY) {
plugins.push(
[
"@babel/plugin-proposal-optional-chaining",
{
loose: true,
},
], // Chrome 80, Firefox 74, Safari 13.1
[
"@babel/plugin-proposal-nullish-coalescing-operator",
{
loose: true,
},
], // Chrome 80, Firefox 72, Safari 13.1
"@babel/plugin-proposal-object-rest-spread", // Chrome 60, Firefox 55, Safari 11.1
"@babel/plugin-transform-for-of", // Chrome 51, Firefox 53
"@babel/plugin-transform-parameters", // Firefox 53
"@babel/plugin-transform-destructuring", // Chrome 51, Firefox 53
"@babel/plugin-transform-exponentiation-operator", // Chrome 52, Firefox 52, Safari 10.1
"@babel/plugin-transform-async-to-generator", // Chrome 55, Firefox 52, Safari 11
);
}
return {
presets: [
[
"@babel/preset-react",
{
runtime: "automatic",
// Results in a ton of warnings from Rollup during watch
// development: process.env.NODE_ENV !== "production",
},
],
"@babel/preset-typescript",
],
plugins,
env: {
test: {
plugins: ["@babel/plugin-transform-modules-commonjs"],
},
},
};
};