2020-03-28 00:35:00 +00:00
|
|
|
module.exports = (api) => {
|
|
|
|
const env = api.env();
|
|
|
|
|
|
|
|
const envOptions = {
|
|
|
|
debug: false,
|
|
|
|
modules: false,
|
2021-07-10 01:47:35 +00:00
|
|
|
useBuiltIns: 'usage',
|
2023-01-23 21:22:10 +00:00
|
|
|
corejs: '3.27',
|
2020-03-28 00:35:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const config = {
|
|
|
|
presets: [
|
|
|
|
'@babel/react',
|
2022-02-27 00:13:35 +00:00
|
|
|
'@babel/typescript',
|
2020-03-28 00:35:00 +00:00
|
|
|
['@babel/env', envOptions],
|
|
|
|
],
|
|
|
|
plugins: [
|
2021-03-29 21:50:08 +00:00
|
|
|
['react-intl', { messagesDir: './build/messages/' }],
|
2020-03-28 00:35:00 +00:00
|
|
|
'preval',
|
|
|
|
],
|
2020-05-17 23:14:52 +00:00
|
|
|
'sourceType': 'unambiguous',
|
2020-03-28 00:35:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
switch (env) {
|
2022-05-11 21:06:35 +00: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-28 00:35:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return config;
|
|
|
|
};
|