yacd/babel.config.js

40 lines
1,010 B
JavaScript
Raw Permalink Normal View History

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,
// new in babel 7.9.0 https://babeljs.io/blog/2020/03/16/7.9.0
2020-06-03 21:44:00 +08:00
bugfixes: true,
},
],
'@babel/preset-react',
2020-06-03 21:44:00 +08:00
'@babel/preset-flow',
'@babel/preset-typescript',
];
2020-06-03 21:44:00 +08:00
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,
2020-06-03 21:44:00 +08:00
useESModules: true,
},
2019-12-20 23:02:10 +08:00
],
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-do-expressions',
2020-06-03 21:44:00 +08:00
isDev ? 'react-refresh/babel' : false,
2019-12-20 23:02:10 +08:00
].filter(Boolean);
return { presets, plugins };
};