forked from neherlab/covid19_scenarios
-
Notifications
You must be signed in to change notification settings - Fork 1
/
babel.config.js
53 lines (48 loc) · 2.05 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
48
49
50
51
52
53
require('./config/dotenv')
function isWebTarget(caller) {
return Boolean(caller && caller.target === 'web')
}
function isWebpack(caller) {
return Boolean(caller && caller.name === 'babel-loader')
}
const development = process.env.NODE_ENV === 'development'
const production = process.env.NODE_ENV === 'production'
const analyze = process.env.ANALYZE === '1'
const debuggableProd = process.env.DEBUGGABLE_PROD === '1'
const loose = true
module.exports = api => {
const web = api.caller(isWebTarget)
const webpack = api.caller(isWebpack)
return {
compact: false,
sourceType: 'unambiguous',
presets: [
'@babel/preset-typescript',
[
'@babel/preset-env',
{
useBuiltIns: web ? 'entry' : undefined,
corejs: web ? 'core-js@3' : false,
targets: !web ? { node: 'current' } : undefined,
modules: webpack ? false : 'commonjs',
loose,
shippedProposals: development,
exclude: ['transform-typeof-symbol'],
},
],
['@babel/preset-react', { useBuiltIns: web, development }],
],
plugins: [
development && web && 'react-refresh/babel',
['@babel/plugin-proposal-numeric-separator', { loose }],
'babel-plugin-lodash',
(development || debuggableProd) && web && !analyze && ['babel-plugin-typescript-to-proptypes', { typeCheck: './src/**/*.ts' }], // prettier-ignore
(development || debuggableProd) && web && !analyze && 'babel-plugin-redux-saga', // prettier-ignore
(development || analyze || debuggableProd) && web && 'babel-plugin-smart-webpack-import', // prettier-ignore
production && web && ['babel-plugin-transform-react-remove-prop-types', { removeImport: true }], // prettier-ignore
production && web && '@babel/plugin-transform-flow-strip-types',
!(development || debuggableProd) && web && '@babel/plugin-transform-react-inline-elements', // prettier-ignore
!(development || debuggableProd) && web && '@babel/plugin-transform-react-constant-elements', // prettier-ignore
].filter(Boolean),
}
}