2018-09-15 01:59:48 +10:00
|
|
|
module.exports = (api) => {
|
|
|
|
const env = api.env();
|
|
|
|
|
2019-12-02 23:38:53 +11:00
|
|
|
const reactOptions = {
|
|
|
|
development: false,
|
2023-05-23 18:52:27 +10:00
|
|
|
runtime: 'automatic',
|
2019-12-02 23:38:53 +11:00
|
|
|
};
|
|
|
|
|
2018-09-15 01:59:48 +10:00
|
|
|
const envOptions = {
|
2023-10-31 21:55:13 +11:00
|
|
|
useBuiltIns: "usage",
|
|
|
|
corejs: { version: "3.30" },
|
2019-12-02 23:38:53 +11:00
|
|
|
debug: false,
|
2023-05-04 00:28:14 +10:00
|
|
|
include: [
|
2023-05-31 17:36:43 +10:00
|
|
|
'transform-numeric-separator',
|
2023-06-14 17:22:54 +10:00
|
|
|
'transform-optional-chaining',
|
|
|
|
'transform-nullish-coalescing-operator',
|
|
|
|
'transform-class-properties',
|
2023-05-04 00:28:14 +10:00
|
|
|
],
|
2018-09-15 01:59:48 +10:00
|
|
|
};
|
|
|
|
|
2023-10-31 21:55:13 +11:00
|
|
|
const plugins = [
|
|
|
|
['formatjs'],
|
|
|
|
'preval',
|
|
|
|
];
|
2018-09-15 01:59:48 +10:00
|
|
|
|
|
|
|
switch (env) {
|
|
|
|
case 'production':
|
2023-10-31 21:55:13 +11:00
|
|
|
plugins.push(...[
|
2018-09-15 01:59:48 +10:00
|
|
|
'lodash',
|
|
|
|
[
|
|
|
|
'transform-react-remove-prop-types',
|
|
|
|
{
|
|
|
|
mode: 'remove',
|
|
|
|
removeImport: true,
|
|
|
|
additionalLibraries: [
|
|
|
|
'react-immutable-proptypes',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
'@babel/transform-react-inline-elements',
|
|
|
|
[
|
|
|
|
'@babel/transform-runtime',
|
|
|
|
{
|
|
|
|
helpers: true,
|
|
|
|
regenerator: false,
|
|
|
|
useESModules: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
break;
|
2023-10-31 21:55:13 +11:00
|
|
|
|
2018-09-15 01:59:48 +10:00
|
|
|
case 'development':
|
2019-12-02 23:38:53 +11:00
|
|
|
reactOptions.development = true;
|
2018-09-15 01:59:48 +10:00
|
|
|
envOptions.debug = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-10-31 21:55:13 +11:00
|
|
|
const config = {
|
|
|
|
presets: [
|
|
|
|
'@babel/preset-typescript',
|
|
|
|
['@babel/react', reactOptions],
|
|
|
|
['@babel/env', envOptions],
|
|
|
|
],
|
|
|
|
plugins,
|
|
|
|
overrides: [
|
|
|
|
{
|
|
|
|
test: /tesseract\.js/,
|
|
|
|
presets: [
|
|
|
|
['@babel/env', { ...envOptions, modules: 'commonjs' }],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
|
2018-09-15 01:59:48 +10:00
|
|
|
return config;
|
|
|
|
};
|