static-cms/packages/core/babel.config.js
Denys Konovalov cebf4d0a9d
Some checks failed
Build / build (push) Waiting to run
Build / lint (push) Waiting to run
Build / test (push) Waiting to run
Build / integration_tests (push) Waiting to run
Cypress Tests / cypress-run (1) (push) Waiting to run
Cypress Tests / cypress-run (2) (push) Waiting to run
CodeQL / Analyze (javascript) (push) Has been cancelled
feat(backend): Add Gitea proxy backend and LFS support for Gitea backend
2024-12-28 11:41:05 +01:00

91 lines
1.7 KiB
JavaScript

const path = require('path');
const coreVersion = require('./package.json').version;
const isProduction = process.env.NODE_ENV === 'production';
const isTest = process.env.NODE_ENV === 'test';
const isESM = process.env.NODE_ENV === 'esm';
console.info('Build Package:', path.basename(process.cwd()));
const defaultPlugins = [
'@sigmacomputing/babel-plugin-lodash',
[
'babel-plugin-transform-builtin-extend',
{
globals: ['Error'],
},
],
'transform-export-extensions',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-export-default-from',
'@babel/plugin-proposal-nullish-coalescing-operator',
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-syntax-dynamic-import',
'babel-plugin-inline-json-import',
];
const svgo = {
plugins: [
{
name: 'preset-default',
params: {
overrides: {
removeViewBox: false,
},
},
},
],
};
function presets() {
return [
'@babel/preset-react',
'@babel/preset-env',
'@babel/typescript',
];
}
function plugins() {
if (isESM) {
return [
...defaultPlugins,
[
'transform-define',
{
STATIC_CMS_CORE_VERSION: `${coreVersion}`,
},
],
[
'inline-react-svg',
{
svgo,
},
],
];
}
if (isTest) {
return [
...defaultPlugins,
[
'inline-react-svg',
{
svgo,
},
],
];
}
if (!isProduction) {
return [...defaultPlugins];
}
return defaultPlugins;
}
module.exports = {
presets: presets(),
plugins: plugins(),
};