[英]How do I add @babel/preset-react to the presets section of babel.config.js
I get this error "React - Add @babel/preset-react ( https://git.io/JfeDR ) to the 'presets' section of your Babel config to enable transformation"我收到此错误“React - 将 @babel/preset-react ( https://git.io/JfeDR ) 添加到 Babel 配置的 'presets' 部分以启用转换”
This is the presets section from my babel.config.js:这是我的 babel.config.js 中的预设部分:
presets: [
isTestEnv && [
'@babel/preset-env',
{
targets: {
node: 'current'
}
}
],
(isProductionEnv || isDevelopmentEnv) && [
'@babel/preset-env',
{
forceAllTransforms: true,
useBuiltIns: 'entry',
corejs: 3,
modules: false,
exclude: ['transform-typeof-symbol']
}
]
].filter(Boolean),
Try:尝试:
],
(isProductionEnv || isDevelopmentEnv) && [
'@babel/preset-env',
{
forceAllTransforms: true,
useBuiltIns: 'usage',
corejs: '3',
modules: false,
exclude: ['transform-typeof-symbol']
}
],
[
'@babel/preset-react',
{
development: isDevelopmentEnv || isTestEnv,
useBuiltIns: true
}
]
].filter(Boolean)
If I am not mistaken, bundle exec rails webpacker:install:react
will add that bit to the babel.config.js
如果我没记错的话,
bundle exec rails webpacker:install:react
会将该位添加到babel.config.js
Here is some useful information which helped me a while back to set up webpacker properly: https://github.com/rails/webpacker/blob/v4.3.0/docs/webpack.md这里有一些有用的信息帮助我正确设置 webpacker: https://github.com/rails/webpacker/blob/v4.3.0/docs/webpack.md
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.