-
Notifications
You must be signed in to change notification settings - Fork 2
/
babel.config.js
47 lines (43 loc) · 1.2 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
47
'use strict'
const packageConfig = require('./package.json')
const createConfig = ({ caller, env }) => {
const { 0: node = '18.16' } =
/(\d+\.?)+/.exec(packageConfig.engines.node) || []
const isDev = env('development')
const isProd = env('production')
const isTest = env('test')
return {
plugins: [
...(isProd
? [
'@babel/transform-react-constant-elements',
'@babel/transform-react-inline-elements',
]
: []),
['@babel/transform-runtime', { corejs: 3, helpers: false }],
'@loadable/babel-plugin',
...(isTest ? [] : ['polished']),
'graphql-tag',
['styled-components', { displayName: isDev, pure: isProd }],
],
presets: [
[
'@babel/preset-env',
caller(({ target = 'node' } = {}) => target === 'node')
? { targets: { node } }
: { corejs: 3, modules: false, useBuiltIns: 'entry' },
],
[
'@babel/preset-react',
{
development: isDev || isTest,
runtime: 'automatic',
useBuiltIns: true,
},
],
'@babel/preset-typescript',
],
ignore: ['build', 'node_modules'],
}
}
module.exports = createConfig