Chatwoot/babel.config.js

75 lines
1.9 KiB
JavaScript
Raw Normal View History

2019-08-21 16:07:06 +00:00
/* eslint-disable global-require */
module.exports = api => {
const validEnv = ['development', 'test', 'production'];
const currentEnv = api.env();
const isDevelopmentEnv = api.env('development');
const isProductionEnv = api.env('production');
const isTestEnv = api.env('test');
if (!validEnv.includes(currentEnv)) {
throw new Error(
2019-08-21 16:07:06 +00:00
`${'Please specify a valid `NODE_ENV` or ' +
'`BABEL_ENV` environment variables. Valid values are "development", ' +
2019-08-21 16:07:06 +00:00
'"test", and "production". Instead, received: '}${JSON.stringify(
currentEnv
)}.`
);
}
return {
presets: [
isTestEnv && [
require('@babel/preset-env').default,
{
targets: {
2019-08-21 16:07:06 +00:00
node: 'current',
},
},
],
(isProductionEnv || isDevelopmentEnv) && [
require('@babel/preset-env').default,
{
forceAllTransforms: true,
useBuiltIns: 'entry',
modules: false,
2019-08-21 16:07:06 +00:00
exclude: ['transform-typeof-symbol'],
},
],
].filter(Boolean),
plugins: [
require('babel-plugin-macros'),
require('@babel/plugin-syntax-dynamic-import').default,
isTestEnv && require('babel-plugin-dynamic-import-node'),
require('@babel/plugin-transform-destructuring').default,
[
require('@babel/plugin-proposal-class-properties').default,
{
2019-08-21 16:07:06 +00:00
loose: true,
},
],
[
require('@babel/plugin-proposal-object-rest-spread').default,
{
2019-08-21 16:07:06 +00:00
useBuiltIns: true,
},
],
[
require('@babel/plugin-transform-runtime').default,
{
helpers: false,
regenerator: true,
2019-08-21 16:07:06 +00:00
corejs: false,
},
],
[
require('@babel/plugin-transform-regenerator').default,
{
2019-08-21 16:07:06 +00:00
async: false,
},
],
2019-08-21 16:07:06 +00:00
[require('babel-plugin-transform-vue-jsx')],
].filter(Boolean),
};
};