## .babelc 文件配置
{
"presets": [
[
"@babel/preset-env",
{... // 让我们忽略其他参数}
],
[
"@babel/preset-react",
{... // 让我们忽略其他参数}
],
],
}
## webpack 配置
rules: [
{
test: /\.jsx?$/,
use: {
loader: 'babel-loader',
options: {
presets: [
"@babel/preset-react",
"@babel/preset-env"
]
}
},
exclude: [
resolve('public'),
resolve('node_modules'),
],
include: [resolve('src')],
},
]
## 这个是报错
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| }
|
> ReactDOM.render(<Index />, document.getElementById('app'));
在网上找了好些地方了,
感觉大家的配置都是这样的啊,一脸懵逼
其实原来配置是可以用的,
尝试jsx一起之后就玩坏了,
在希望退版本就不行了,萌新望天,求大佬搭把手
修改 .jsx? 和 .tsx? 的配置走 .babelrc 的配置