-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbabel.config.js
More file actions
33 lines (26 loc) · 851 Bytes
/
Copy pathbabel.config.js
File metadata and controls
33 lines (26 loc) · 851 Bytes
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
//@ts-check
/**
* @typedef {false | null | undefined | 0 | ''} Falsy
* @typedef {<T>(x: Falsy | T) => x is T} TruthyPredicate
*/
/** @type {import('@babel/core').ConfigFunction} */
const getConfig = (api) => {
const isDev = process.env.NODE_ENV === 'development';
api.cache.using(() => process.env.NODE_ENV);
/** @type {import('@babel/core').TransformOptions['presets']} */
const presets = [
['@babel/preset-env'],
['@babel/preset-react', { runtime: 'automatic' }],
'@babel/preset-typescript',
];
/** @type {import('@babel/core').TransformOptions['plugins']} */
const plugins = [
'@babel/plugin-proposal-class-properties',
isDev && 'react-refresh/babel',
].filter(/** @type {TruthyPredicate} */ (/** @type {unknown} */ (Boolean)));
return {
presets,
plugins,
};
};
module.exports = getConfig;