-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbabel.config.js
35 lines (31 loc) · 1.06 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
module.exports = (api) => {
api.cache.using(() => process.env.NODE_ENV)
const web = api.caller((caller) => Boolean(caller && caller.target === 'web'))
const presets = [
[
'@babel/preset-env',
{
targets: web ? 'defaults' : { node: process.versions.node }, // https://babeljs.io/docs/en/options#targets
useBuiltIns: web ? 'usage' : false, // https://babeljs.io/docs/en/babel-preset-env#usebuiltins
...(web && { corejs: { version: '3.25', proposals: false } }), // https://babeljs.io/docs/en/babel-preset-env#usebuiltins
shippedProposals: web,
debug: false // https://babeljs.io/docs/en/babel-preset-env#debug
}
],
[
'@babel/preset-react',
{
development: process.env.NODE_ENV === 'development' // https://babeljs.io/docs/en/babel-preset-react/#development
}
],
'@babel/preset-typescript'
]
const plugins = ['@loadable/babel-plugin']
if (web && process.env.NODE_ENV === 'development') {
plugins.push('react-refresh/babel')
}
return {
presets,
plugins
}
}