reactjs - 将resourceQuery 与Webpack v3.8.1 结合使用

标签 reactjs svg webpack

我想加载一些.svg文件直接进入 DOM进入<svg>标签。区分.svg应使用 svg-sprite-loader 以这种方式加载的文件以及那些应该作为带有 file-loader 的文件加载的文件,我打算使用resourceQuery .

我的webpack.config.dev.js中有这个

      {
        test: /\.svg$/,
        oneOf: [
          {
            resourceQuery: /sprite/,
            use: require.resolve('svg-sprite-loader'),
          },
          {
            use: {
              loader: require.resolve('file-loader'),
              options: {
                name: 'static/media/[name].[hash:8].[ext]',
              },
            }
          }
        ],
      }

在我的一个文件中,有以下内容:

import '../../../images/dropdown.svg?sprite';

我经常遇到以下错误:

Unable to resolve path to module '../../../images/dropdown.svg?sprite'  import/no-unresolved

我不确定什么是不正确的。请帮忙解决。

最佳答案

正如@PlayMa256建议的那样,忽略eslint-error:

    "import/extensions": 0,
    "import/no-unresolved": 0,

.eslintrc

关于reactjs - 将resourceQuery 与Webpack v3.8.1 结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51658733/

相关文章:

ruby-on-rails - 本地运行 React/Rails 应用程序

reactjs - 将 react 查询的测试与测试库集成

javascript - react 形式 : Updating the UI based on the Axios GET call response in withFormik()

javascript - 在 Webpack 4 中创建 Node 库

reactjs - 如何在不发生突变的情况下重新获取查询

image - 如何指定要在 SVG 中渲染的图像部分 :image tag?

html - SVG中的反透明区域

html - 重复 CSS 关键帧动画

typescript - 如何为 ts-loader 指定 typescript 版本?

typescript - TypeORM ColumnTypeUndefined 错误排查步骤?