39 lines
739 B
JavaScript
39 lines
739 B
JavaScript
const Environment = {
|
|
development: "development",
|
|
production: "production",
|
|
};
|
|
|
|
module.exports = (api) => {
|
|
const presets = [
|
|
[
|
|
"@babel/preset-env",
|
|
{
|
|
useBuiltIns: "usage",
|
|
debug: false,
|
|
corejs: 3,
|
|
},
|
|
],
|
|
"@babel/preset-react",
|
|
];
|
|
const plugins = [
|
|
"@babel/plugin-syntax-dynamic-import",
|
|
];
|
|
|
|
const environment = api.cache.using(() => {
|
|
const env = process.env.NODE_ENV ?? Environment.production;
|
|
return env;
|
|
});
|
|
console.log(`Current environment: '${environment}'`);
|
|
switch (environment) {
|
|
case Environment.development:
|
|
plugins.push("react-refresh/babel");
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return {
|
|
presets,
|
|
plugins,
|
|
};
|
|
};
|