generated from timelessco/react-ts-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
babel.config.js
43 lines (39 loc) · 1.08 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
const BABEL_ENV = process.env.BABEL_ENV;
const isCommonJS = BABEL_ENV !== undefined && BABEL_ENV === "cjs";
const isESM = BABEL_ENV !== undefined && BABEL_ENV === "esm";
const isBuild = !!BABEL_ENV;
module.exports = function (api) {
api.cache(true);
const presets = [
[
"@babel/env",
{
modules: isCommonJS ? "commonjs" : false,
targets: { esmodules: isESM ? true : undefined },
},
],
["@babel/preset-react", { runtime: "automatic" }],
"@babel/preset-typescript",
];
const plugins = [
["@babel/plugin-proposal-private-methods", { loose: true }],
["@babel/plugin-proposal-class-properties", { loose: true }],
["@babel/plugin-proposal-private-property-in-object", { loose: true }],
isBuild
? [
"babel-plugin-jsx-remove-data-test-id",
{ attributes: ["data-testid"] },
]
: {},
];
return {
presets,
plugins,
env: {
test: {
presets: [["@babel/env", { targets: { node: "current" } }]],
},
},
ignore: isBuild ? ["**/*/stories", "**/__tests__"] : [],
};
};