yacd/babel.config.js

39 lines
896 B
JavaScript
Raw Normal View History

'use strict';
const presets = [
[
'@babel/preset-env',
{
modules: false,
2019-03-12 23:48:37 +08:00
// see also zloirock/core-js https://bit.ly/2JLnrgw
useBuiltIns: 'usage',
corejs: 3
}
],
'@babel/preset-react',
'@babel/preset-flow'
];
module.exports = api => {
2020-01-15 13:07:08 +08:00
// https://babeljs.io/docs/en/config-files#apicache
2019-12-20 23:02:10 +08:00
api.cache.using(() => process.env.NODE_ENV);
2020-01-15 13:07:08 +08:00
// https://babeljs.io/docs/en/config-files#apienv
2019-12-20 23:02:10 +08:00
const isDev = api.env('development');
const plugins = [
[
'@babel/plugin-transform-runtime',
{
corejs: false,
helpers: true,
regenerator: true,
useESModules: true
}
],
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-do-expressions',
isDev ? 'react-refresh/babel' : false
].filter(Boolean);
return { presets, plugins };
};