.babelrc.js 还可以这么配置
module.exports =(api)=> {
api.cache.using(() => process.env.NODE_ENV);
console.log('开发环境识别',api.env('development') )
return {
"presets": [
"react-app"
],
"plugins": [
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-proposal-optional-chaining",
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-proposal-class-properties", { "loose" : true }],
["import", { "libraryName": "antd", "style": true }, "antd"],
[
"ramda",
{
"useES": true
}
],
"lodash",
!api.env('production') && 'react-refresh/babel'
].filter(Boolean)
}
}