JetBrains / svg-sprite-loader

Webpack loader for creating SVG sprites.
MIT License
2.02k stars 271 forks source link

Error: Rule can only have one resource source (provided resource and test + include + exclude) in 6.0.0 #443

Open stefpb opened 3 years ago

stefpb commented 3 years ago

Do you want to request a feature, report a bug or ask a question? Report a bug for the newst version

What is the current behavior? image

[webpack-cli] Error: Rule can only have one resource source (provided resource and test + include + exclude) in {
  "enforce": "pre",
  "loader": "eslint-loader",
  "options": {
    "configFile": "./.eslintrc.js"
  },
  "exclude": [
    {},
    "/var/www/html/assets/Yves/shared/img"
  ],
  "include": [
    "/var/www/html/assets/Yves/opus/app",
    "/var/www/html/assets/Yves/shared"
  ]
}
    at checkResourceSource (/var/www/html/node_modules/webpack/lib/RuleSet.js:167:11)
    at Function.normalizeRule (/var/www/html/node_modules/webpack/lib/RuleSet.js:198:4)
    at /var/www/html/node_modules/webpack/lib/RuleSet.js:110:20
    at Array.map (<anonymous>)
    at Function.normalizeRules (/var/www/html/node_modules/webpack/lib/RuleSet.js:109:17)
    at new RuleSet (/var/www/html/node_modules/webpack/lib/RuleSet.js:104:24)
    at module.exports (/var/www/html/assets/node_modules/svg-sprite-loader/lib/utils/get-matched-rule-4.js:15:21)
    at SVGSpritePlugin.apply (/var/www/html/assets/node_modules/svg-sprite-loader/lib/plugin.js:61:18)
    at createCompiler (/var/www/html/assets/node_modules/webpack/lib/webpack.js:71:12)
    at create (/var/www/html/assets/node_modules/webpack/lib/webpack.js:118:16) 
    at webpack (/var/www/html/assets/node_modules/webpack/lib/webpack.js:126:47)
    at WebpackCLI.f [as webpack] (/var/www/html/assets/node_modules/webpack/lib/index.js:41:15)
    at WebpackCLI.createCompiler (/var/www/html/assets/node_modules/webpack-cli/lib/webpack-cli.js:1678:29)
    at WebpackCLI.buildCommand (/var/www/html/assets/node_modules/webpack-cli/lib/webpack-cli.js:1785:20)
    at Command.<anonymous> (/var/www/html/assets/node_modules/webpack-cli/lib/webpack-cli.js:564:25)
    at async Promise.all (index 1)
error Command failed with exit code 2.

What is the expected behavior? Webpack runs through.

Please tell us about your environment:

Other information

      {
        test: /\.svg$/,
        include: [
          path.resolve(settings.paths.sourceDir, 'img'),
          path.join(path.resolve('./Yves'), '/shared'),
        ],
        use: [
          {
            loader: 'svg-sprite-loader',
            options: {
              // extract: ifProduction(true, false),
              // plainSprite: true,
              // esModule: false,
              spriteFilename: (svgPath) => `img/sprite.[contenthash]${svgPath.substr(-4)}`,
            },
          },
          'svg-transform-loader',
          'svgo-loader',
        ],
      },

Downgrade svg-sprite-loader to 5.2.1 solve this problem, but than i have deprecated warnings.

d3x42 commented 3 years ago

Could you please provide a git report with the same reproduced issue?

stefpb commented 3 years ago

I updated to 6.0.2 and rerun webpack again and i get the same error:

image

$ NODE_ENV=production THEME=opus webpack --config=./webpack/webpack.prod.babel.js --mode production
[webpack-cli] Error: Rule can only have one resource source (provided resource and test + include + exclude) in {
  "include": [
    "/var/www/html/assets/Yves/opus",
    "/var/www/html/assets/Yves/shared"
  ],
  "exclude": {},
  "use": [
    {
      "loader": "babel-loader",
      "options": {
        "cacheDirectory": true
      },
      "ident": "clonedRuleSet-1[0].rules[0]"
    }
  ]
}
    at checkResourceSource (/var/www/html/node_modules/webpack/lib/RuleSet.js:167:11)
    at Function.normalizeRule (/var/www/html/node_modules/webpack/lib/RuleSet.js:198:4)
    at /var/www/html/node_modules/webpack/lib/RuleSet.js:110:20
    at Array.map (<anonymous>)
    at Function.normalizeRules (/var/www/html/node_modules/webpack/lib/RuleSet.js:109:17)
    at new RuleSet (/var/www/html/node_modules/webpack/lib/RuleSet.js:104:24)
    at module.exports (/var/www/html/assets/node_modules/svg-sprite-loader/lib/utils/get-matched-rule-4.js:15:21)
    at SVGSpritePlugin.apply (/var/www/html/assets/node_modules/svg-sprite-loader/lib/plugin.js:61:18)
    at createCompiler (/var/www/html/assets/node_modules/webpack/lib/webpack.js:71:12)
    at create (/var/www/html/assets/node_modules/webpack/lib/webpack.js:118:16)
    at webpack (/var/www/html/assets/node_modules/webpack/lib/webpack.js:126:47)
    at WebpackCLI.f [as webpack] (/var/www/html/assets/node_modules/webpack/lib/index.js:41:15)
    at WebpackCLI.createCompiler (/var/www/html/assets/node_modules/webpack-cli/lib/webpack-cli.js:1678:29)
    at WebpackCLI.buildCommand (/var/www/html/assets/node_modules/webpack-cli/lib/webpack-cli.js:1785:20)
    at Command.<anonymous> (/var/www/html/assets/node_modules/webpack-cli/lib/webpack-cli.js:564:25)
    at async Promise.all (index 1)
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

In the meantime i replaced eslint-loader to eslint-webpack-plugin, so the message is a little bit different. With the svg-sprite-loader v5.2.1 it runs through, but there i get

(node:1792) [DEP_WEBPACK_COMPILATION_NORMAL_MODULE_LOADER_HOOK] DeprecationWarning: Compilation.hooks.normalModuleLoader was moved to NormalModule.getCompilationHooks(compilation).loader
    at getNormalModuleLoader (/var/www/html/assets/node_modules/webpack/lib/Compilation.js:333:39)
    at Object.get normalModuleLoader [as normalModuleLoader] (/var/www/html/assets/node_modules/webpack/lib/Compilation.js:753:12)
    at /var/www/html/assets/node_modules/svg-sprite-loader/lib/plugin.js:74:14
    at Hook.eval (eval at create (/var/www/html/assets/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:12:1)
    at Hook.CALL_DELEGATE [as _call] (/var/www/html/assets/node_modules/tapable/lib/Hook.js:14:14)
    at Compiler.newCompilation (/var/www/html/assets/node_modules/webpack/lib/Compiler.js:992:30)
    at /var/www/html/assets/node_modules/webpack/lib/Compiler.js:1035:29
    at Hook.eval [as callAsync] (eval at create (/var/www/html/assets/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:22:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/var/www/html/assets/node_modules/tapable/lib/Hook.js:18:14)
    at Compiler.compile (/var/www/html/assets/node_modules/webpack/lib/Compiler.js:1030:28)
    at /var/www/html/assets/node_modules/webpack/lib/Compiler.js:473:12
    at Compiler.readRecords (/var/www/html/assets/node_modules/webpack/lib/Compiler.js:871:11)
    at /var/www/html/assets/node_modules/webpack/lib/Compiler.js:470:11
    at eval (eval at create (/var/www/html/assets/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:19:1)
    at /var/www/html/assets/node_modules/stylelint-webpack-plugin/dist/linter.js:73:7
(node:1792) [DEP_WEBPACK_MODULE_ISSUER] DeprecationWarning: Module.issuer: Use new ModuleGraph API
    at Function.getModuleGraphForModule (/var/www/html/assets/node_modules/webpack/lib/ModuleGraph.js:730:10)
    at NormalModule.get issuer [as issuer] (/var/www/html/assets/node_modules/webpack/lib/Module.js:276:22)
    at Object.isModuleShouldBeExtracted (/var/www/html/assets/node_modules/svg-sprite-loader/lib/utils/is-module-should-be-extracted.js:11:20)
    at configurator (/var/www/html/assets/node_modules/svg-sprite-loader/lib/configurator.js:26:20)
    at Object.loader (/var/www/html/assets/node_modules/svg-sprite-loader/lib/loader.js:39:18)
    at LOADER_EXECUTION (/var/www/html/assets/node_modules/loader-runner/lib/LoaderRunner.js:132:14)
    at runSyncOrAsync (/var/www/html/assets/node_modules/loader-runner/lib/LoaderRunner.js:133:4)
    at iterateNormalLoaders (/var/www/html/assets/node_modules/loader-runner/lib/LoaderRunner.js:250:2)
    at iterateNormalLoaders (/var/www/html/assets/node_modules/loader-runner/lib/LoaderRunner.js:239:10)
    at /var/www/html/assets/node_modules/loader-runner/lib/LoaderRunner.js:254:3
    at context.callback (/var/www/html/assets/node_modules/loader-runner/lib/LoaderRunner.js:124:13)
    at Object.module.exports (/var/www/html/assets/node_modules/svg-transform-loader/lib/loader.js:34:12)
    at LOADER_EXECUTION (/var/www/html/assets/node_modules/loader-runner/lib/LoaderRunner.js:132:14)
    at runSyncOrAsync (/var/www/html/assets/node_modules/loader-runner/lib/LoaderRunner.js:133:4)
    at iterateNormalLoaders (/var/www/html/assets/node_modules/loader-runner/lib/LoaderRunner.js:250:2)
    at iterateNormalLoaders (/var/www/html/assets/node_modules/loader-runner/lib/LoaderRunner.js:239:10)

(But that is what you know, right?)

d3x42 commented 3 years ago

Please try svg-sprite-loader@6.0.4

stefpb commented 3 years ago

With svg-sprite-loader@6.0.5 the same error :/

Also with the newest webpack-version of 5.31.2

Tell me if there is any way I can support you better. I really want to help as best I can.

d3x42 commented 3 years ago

@stefpb It would be great if you could create a small repo with the reproduced issue.