-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbabel.config.js
73 lines (60 loc) · 1.44 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
const fs = require("fs");
const path = require("path");
const getEnvFile = () => {
try {
fs.statSync(path.resolve(__dirname, "./.env"));
return path.resolve(__dirname, "./.env");
} catch (err) {
return path.resolve(__dirname, "./.env.sample");
}
};
const getConfig = env => {
const plugins = [
"@babel/plugin-proposal-class-properties",
[
"babel-plugin-inline-import",
{
extensions: [".glsl"]
}
],
[
"babel-plugin-inline-dotenv",
{
path: getEnvFile(),
systemVar: "overwrite",
env:
(env === "test" && { GIST_ID: "3b267cd582f17544bdd923d9e75b8223" }) ||
{}
}
],
"@babel/plugin-syntax-dynamic-import"
];
const presets = [
"@emotion/babel-preset-css-prop",
"@babel/preset-typescript",
"@babel/preset-react"
];
if (env === "test") {
plugins.push("@babel/plugin-transform-modules-commonjs");
}
if (env === "production") {
presets.push([
"@babel/preset-env",
{
targets: {
firefox: "70",
chrome: "79",
edge: "18",
safari: "13",
ios: "13"
// ie: '11',
},
useBuiltIns: false,
modules: false
}
]);
}
return { plugins, presets };
};
module.exports = api => getConfig(api.env());
module.exports.getConfig = getConfig;