theatre/babel.config.js
2021-08-06 12:00:19 +02:00

24 lines
793 B
JavaScript

module.exports = function (api) {
const env = api.env()
const config = {
presets: [['@babel/preset-react'], ['@babel/preset-typescript']],
babelrcRoots: ['.', './packages/*', './theatre/*', './examples/*'],
}
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
}