-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.babelrc.js
66 lines (61 loc) · 1.84 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
54
55
56
57
58
59
60
61
62
63
64
65
66
/** @format */
const isDev = !process.env.NODE_ENV || process.env.NODE_ENV.startsWith("dev");
const isProduction = !isDev && process.env.NODE_ENV.startsWith("prod");
const presets = [
[
"@babel/preset-env",
{
loose: true,
useBuiltIns: "usage",
corejs: {
version: 3,
proposals: true,
},
shippedProposals: true,
},
],
];
const plugins = [
["@babel/plugin-proposal-class-properties", { loose: true }],
"@babel/plugin-proposal-export-default-from",
"@babel/plugin-proposal-export-namespace-from",
"@babel/plugin-proposal-function-bind",
"@babel/plugin-proposal-logical-assignment-operators",
["@babel/plugin-proposal-nullish-coalescing-operator", { loose: true }],
["@babel/plugin-proposal-optional-chaining", { loose: true }],
"@babel/plugin-proposal-throw-expressions",
"babel-plugin-import-directory",
"babel-plugin-transform-promise-to-bluebird",
];
if (!isDev) {
presets.unshift(
// Presets are executed from last to first, so these go at the front to go last
"minify",
);
plugins.push(
// Plugins are executed from first to last, so these go at the end to go last
"babel-plugin-lodash", // This is specially-tuned to support modularizing Lodash imports.
[
// This is a more general-purpose way to modularize imports.
// It's super useful for enabling tree shaking, assuming the imported library has a sane organization.
"babel-plugin-transform-imports",
{},
],
"babel-plugin-remove-debug",
"babel-plugin-transform-remove-debugger",
"babel-plugin-transform-remove-console",
"babel-plugin-minify-constant-folding",
"babel-plugin-minify-simplify",
"babel-plugin-minify-dead-code-elimination",
);
}
module.exports = {
presets,
plugins,
sourceMaps: true,
retainLines: isDev,
compact: isProduction,
minified: isProduction,
comments: isDev,
ignore: isProduction ? [/^.*\.test\.js$/i] : [],
};