-
Notifications
You must be signed in to change notification settings - Fork 6
/
babel.config.js
42 lines (37 loc) · 939 Bytes
/
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
const env = process.env.BABEL_ENV || process.env.NODE_ENV || "development";
const isEnvTest = env === "test";
// ES2015+
const envPreset = [
require.resolve("@babel/preset-env"),
{
useBuiltIns: "entry",
corejs: "core-js@3",
modules: false,
targets: "> 0.25%, not dead",
},
];
// Test Build
const envPresetTest = [
require.resolve("@babel/preset-env"),
{
useBuiltIns: "entry",
corejs: "core-js@3",
targets: { node: "current" },
},
];
// Commons
const commonPlugins = [
[require.resolve("@babel/plugin-proposal-class-properties"), { lose: true }],
[require.resolve("@babel/plugin-proposal-private-methods"), { lose: true }],
];
// Export
module.exports = (api, opts) => {
console.log("Building for:", env);
api.cache(true);
return {
presets: [!isEnvTest && envPreset, isEnvTest && envPresetTest].filter(
Boolean
),
plugins: [...commonPlugins].filter(Boolean),
};
};