2018-11-08 22:37:12 +08:00
|
|
|
'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
|
2019-10-02 23:36:24 +08:00
|
|
|
useBuiltIns: 'usage',
|
2019-05-27 23:03:21 +08:00
|
|
|
corejs: 3
|
2018-11-08 22:37:12 +08:00
|
|
|
}
|
|
|
|
],
|
2019-12-01 22:41:59 +08:00
|
|
|
'@babel/preset-react',
|
|
|
|
'@babel/preset-flow'
|
2018-11-08 22:37:12 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
module.exports = api => {
|
2019-12-20 23:02:10 +08:00
|
|
|
api.cache.using(() => process.env.NODE_ENV);
|
|
|
|
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);
|
2018-11-08 22:37:12 +08:00
|
|
|
return { presets, plugins };
|
|
|
|
};
|