2020-03-27 17:35:00 -07:00
|
|
|
module.exports = (api) => {
|
|
|
|
const env = api.env();
|
|
|
|
|
|
|
|
const envOptions = {
|
|
|
|
debug: false,
|
|
|
|
modules: false,
|
2021-07-09 18:47:35 -07:00
|
|
|
useBuiltIns: 'usage',
|
2023-01-23 13:22:10 -08:00
|
|
|
corejs: '3.27',
|
2020-03-27 17:35:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
const config = {
|
|
|
|
presets: [
|
|
|
|
'@babel/react',
|
2022-02-26 16:13:35 -08:00
|
|
|
'@babel/typescript',
|
2020-03-27 17:35:00 -07:00
|
|
|
['@babel/env', envOptions],
|
|
|
|
],
|
|
|
|
plugins: [
|
2021-03-29 14:50:08 -07:00
|
|
|
['react-intl', { messagesDir: './build/messages/' }],
|
2020-03-27 17:35:00 -07:00
|
|
|
'preval',
|
|
|
|
],
|
2020-05-17 16:14:52 -07:00
|
|
|
'sourceType': 'unambiguous',
|
2020-03-27 17:35:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
switch (env) {
|
2022-05-11 14:06:35 -07:00
|
|
|
case 'production':
|
|
|
|
config.plugins.push(...[
|
|
|
|
'@babel/transform-react-inline-elements',
|
|
|
|
[
|
|
|
|
'@babel/transform-runtime',
|
|
|
|
{
|
|
|
|
helpers: true,
|
|
|
|
regenerator: false,
|
|
|
|
useESModules: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
break;
|
|
|
|
case 'test':
|
|
|
|
config.plugins.push(...[
|
|
|
|
'transform-require-context',
|
|
|
|
]);
|
|
|
|
envOptions.modules = 'commonjs';
|
|
|
|
break;
|
2020-03-27 17:35:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return config;
|
|
|
|
};
|