简体   繁体   English

create-react-app 和 svgr 的 webpack 错误

[英]webpack errors with create-react-app & svgr

I created react app by using create-react-app and 2 days ago i run npm run eject follows by i added @svgr/webpack into project it was working perfectly at the time.我使用 create-react-app 创建了 react 应用程序,2 天前我运行npm run eject我将@svgr/webpack添加到项目中,当时它运行良好。 I just get back to do some undone work, but when i run yarn start the error it's showed in the command:我只是回来做一些未完成的工作,但是当我运行yarn start ,它显示在命令中的错误:

options/query provided without loader (use loader + options) in {
  "test": [
    {},
    {},
    {},
    {},
    {}
  ],
  "use": [
    "@svgr/webpack",
    "url-loader"
  ],
  "options": {
    "limit": 10000,
    "name": "static/media/[name].[hash:8].[ext]"
  }
}

follow the error message i change webpack.config.js to按照我将 webpack.config.js 更改为的错误消息

{
  test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/, /\.svg$/],
  loader: ['@svgr/webpack', 'url-loader'],
    options: {
      limit: imageInlineSizeLimit,
      name: 'static/media/[name].[hash:8].[ext]',
    },
  },

it then shows然后它显示

options/query cannot be used with loaders (use options for each array item) in {
  "test": [
    {},
    {},
    {},
    {},
    {}
  ],
  "loader": [
    "@svgr/webpack",
    "url-loader"
  ],
  "options": {
    "limit": 10000,
    "name": "static/media/[name].[hash:8].[ext]"
  }
}

Anybody have the workaround to solve this problem.任何人都有解决此问题的方法。

Github issues Github 问题

Try changing your configuration to尝试将您的配置更改为

{
  test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/, /\.svg$/],
  use: [{
    loader: '@svgr/webpack',
    options: {
      limit: imageInlineSizeLimit,
      name: 'static/media/[name].[hash:8].[ext]',
    }
  },
  {
    loader: 'url-loader'
  }]      
},

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我应该使用 webpack 还是 create-react-app? - Should i use webpack or create-react-app? Webpack 错误将故事书添加到 create-react-app - Webpack error adding storybook to create-react-app 有没有办法在不弹出的情况下为 create-react-app 更改 webpack 的 eslint - Is there a way to change the eslint of the webpack for the create-react-app without ejecting create-react-app webpack 配置和文件在哪里? - where is create-react-app webpack config and files? 什么是webpack.DefinePlugin的create-react-app的好选择? - What is a good alternative to webpack.DefinePlugin for create-react-app? 使用 create-react-app 和 webpack dev server 将来自客户端反应应用程序的请求代理到服务器 - Proxying requests from client react app to server with create-react-app and webpack dev server 将React Webpack应用程序(不是使用create-react-app创建)部署到Github页面 - Deploying a React Webpack app (not created with create-react-app) to Github pages 如何为使用 create-react-app 创建的 react 项目更新 webpack 配置? - How to update webpack config for a react project created using create-react-app? 带有 Create-react-app 的 Cordova - Cordova with Create-react-app Webpack要求使用Create-React-App时抛出目标容器不是DOM元素吗? - Webpack required throwing Target container is not a DOM element when using Create-React-App?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM