2021-06-18 13:05:06 +02:00
|
|
|
module.exports = function (api) {
|
|
|
|
const env = api.env()
|
|
|
|
|
|
|
|
const config = {
|
|
|
|
presets: [['@babel/preset-react'], ['@babel/preset-typescript']],
|
2021-08-06 12:00:19 +02:00
|
|
|
babelrcRoots: ['.', './packages/*', './theatre/*', './examples/*'],
|
2021-06-18 13:05:06 +02:00
|
|
|
}
|
|
|
|
if (env === 'test') {
|
|
|
|
config.presets.unshift(['@babel/preset-env', {targets: {node: 'current'}}])
|
|
|
|
} else {
|
|
|
|
if (env === 'development' || env === 'production') {
|
|
|
|
config.plugins.unshift(
|
|
|
|
['@babel/plugin-proposal-class-properties', {loose: true}],
|
|
|
|
['@babel/plugin-proposal-optional-chaining'],
|
|
|
|
['@babel/plugin-proposal-nullish-coalescing-operator'],
|
|
|
|
['@babel/plugin-proposal-logical-assignment-operators'],
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
throw Error(`Babel env ` + env + ' is not yet configured.')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return config
|
|
|
|
}
|