forked from ariakit/ariakit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
babel.config.js
46 lines (43 loc) · 1.04 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
// @ts-check
const test = process.env.NODE_ENV === "test";
const prod = process.env.NODE_ENV === "production";
const { warn } = console;
// Prevents resolution warnings from babel-plugin-module-resolver
// See https://github.com/tleunen/babel-plugin-module-resolver/issues/315
// eslint-disable-next-line no-console
console.warn = (...args) => {
for (const arg of args) {
if (arg.startsWith("Could not resolve") && /src/.test(arg)) {
return;
}
}
warn(...args);
};
/** @type {import("@babel/core").ParserOptions} */
module.exports = {
presets: [
[
"@babel/preset-env",
{
loose: true,
targets: test
? { node: "current" }
: {
browsers: "defaults, not IE 11",
},
},
],
["@babel/preset-react", { runtime: "automatic" }],
"@babel/preset-typescript",
],
plugins: [
!prod && [
"babel-plugin-module-resolver",
{
alias: {
"^ariakit([^/]*)(.*)$": "ariakit\\1/src\\2",
},
},
],
].filter(Boolean),
};