-
Notifications
You must be signed in to change notification settings - Fork 0
/
.babelrc.js
41 lines (38 loc) · 1.24 KB
/
.babelrc.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
const importExternalHelpers = require('./plugins/babelPluginImportExternalHelpers')
const getPresets = () => [
['@babel/preset-env', { targets: { browsers: ['ie >= 11'] }, modules: false }],
'@babel/preset-react'
]
const getPlugins = (modules, forProduction = true, logoutHelpers) => {
const plugins = [
['@babel/plugin-proposal-object-rest-spread', { loose: true }],
[importExternalHelpers, {
modules,
root: 'src',
path: './utils/babelHelpers.js',
logoutHelpers,
removeExportsInitialization: true
}]
]
if (modules === 'commonjs') {
plugins.push(['@babel/plugin-transform-modules-commonjs', { loose: true }])
}
if (forProduction) {
plugins.push(['babel-plugin-transform-react-remove-prop-types', { removeImport: true }])
}
return plugins
}
module.exports = api => {
api.assertVersion(7)
api.cache.invalidate(() => process.env.NODE_ENV)
const presets = getPresets()
return {
exclude: '/**/node_modules/**',
env: {
production: { presets, plugins: getPlugins('commonjs') },
es: { presets, plugins: getPlugins(false) },
test: { presets, plugins: getPlugins('commonjs', false) },
helpers: { presets, plugins: getPlugins('commonjs', false, true) }
}
}
}