forked from kriasoft/react-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbabel.config.cjs
52 lines (49 loc) · 1.24 KB
/
babel.config.cjs
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
/* SPDX-FileCopyrightText: 2014-present Kriasoft */
/* SPDX-License-Identifier: MIT */
/**
* Babel configuration.
*
* @see https://babeljs.io/docs/en/options
* @param {import("@babel/core").ConfigAPI} api
* @returns {import("@babel/core").TransformOptions}
*/
module.exports = function config(api) {
return {
presets: ["@babel/preset-env"],
plugins: [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-object-rest-spread",
],
overrides: [
{
test: /\.tsx?$/,
presets: ["@babel/preset-typescript"],
plugins: [
api.env("test") && [
"replace-import-extension",
{ extMapping: { ".js": ".ts" } },
],
].filter(Boolean),
},
{
test: /\.tsx$/,
presets: [
[
"@babel/preset-react",
{
development: api.env() === "development",
useBuiltIns: true,
runtime: "automatic",
importSource: "@emotion/react",
},
],
],
plugins: ["@emotion/babel-plugin"],
},
{
test: "**/*.d.ts",
presets: [["@babel/preset-env", { targets: { esmodules: true } }]],
},
],
};
};