File was processed with these loaders: * ./node_modules/@pmmmwh/react-refresh-webpack-plugin/loader/index.js You may need an additional loader to handle the result of these loaders. | import "./App.less"; | > const Container: React.FC<{}> = () => { | return ( | <>
时间: 2024-02-21 13:59:43 浏览: 24
这个错误通常是由于缺少对应的 loader 导致的。根据错误提示信息,你使用了 `react-refresh-webpack-plugin` 这个插件,而这个插件使用了一个自定义的 loader。可能的解决方法是在 webpack 配置文件中添加一个额外的 loader,用来处理这个插件的返回值。你可以尝试在 webpack 配置文件中添加如下代码:
```js
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-react'],
},
},
},
{
test: /\.less$/,
use: [
{
loader: 'style-loader',
},
{
loader: 'css-loader',
},
{
loader: 'less-loader',
},
],
},
// 添加这个 loader 处理 react-refresh-webpack-plugin 的返回值
{
test: /react-refresh-webpack-plugin/,
use: [
{
loader: 'babel-loader',
options: {
plugins: ['react-refresh/babel'],
},
},
],
},
],
},
```
这段代码中,我们针对 `react-refresh-webpack-plugin` 添加了一个 babel-loader,用来处理该插件的返回值。注意,这个 loader 的 `test` 属性需要设置成 `react-refresh-webpack-plugin`,这样才能正确匹配到该插件的返回值。