JetBrains / svg-sprite-loader

Webpack loader for creating SVG sprites.
MIT License
2.01k stars 272 forks source link

Compiling RuleSet failed: Properties mimetype are unknown #458

Closed jpvanhal closed 3 years ago

jpvanhal commented 3 years ago

Do you want to request a feature, report a bug or ask a question?

Bug

What is the current behavior?

Using SpriteLoaderPlugin together with Rule.mimetype results in the error:

Error: Compiling RuleSet failed: Properties mimetype are unknown (at ruleSet[0].rules[0]: [object Object])
    at RuleSetCompiler.error (./node_modules/webpack/lib/rules/RuleSetCompiler.js:373:10)
    at RuleSetCompiler.compileRule (./node_modules/webpack/lib/rules/RuleSetCompiler.js:196:15)
    at ./node_modules/webpack/lib/rules/RuleSetCompiler.js:154:9
    at Array.map (<anonymous>)
    at RuleSetCompiler.compileRules (./node_modules/webpack/lib/rules/RuleSetCompiler.js:153:16)
    at RuleSetCompiler.compileRule (./node_modules/webpack/lib/rules/RuleSetCompiler.js:184:30)
    at ./node_modules/webpack/lib/rules/RuleSetCompiler.js:154:9
    at Array.map (<anonymous>)
    at RuleSetCompiler.compileRules (./node_modules/webpack/lib/rules/RuleSetCompiler.js:153:16)
    at RuleSetCompiler.compile (./node_modules/webpack/lib/rules/RuleSetCompiler.js:68:22)
    at module.exports (./node_modules/svg-sprite-loader/lib/utils/get-matched-rule-5.js:45:37)
    at SVGSpritePlugin.apply (./node_modules/svg-sprite-loader/lib/plugin.js:61:18)
    at createCompiler (./node_modules/webpack/lib/webpack.js:74:12)
    at create (./node_modules/webpack/lib/webpack.js:123:16)
    at webpack (./node_modules/webpack/lib/webpack.js:131:47)
    at WebpackCLI.f [as webpack] (./node_modules/webpack/lib/index.js:54:15)

What is the expected behavior?

No errors.

If the current behavior is a bug, please provide the steps to reproduce, at least part of webpack config with loader configuration and piece of your code.

webpack.config.js:

const SpriteLoaderPlugin = require('svg-sprite-loader/plugin');

module.exports = {
  mode: 'development',
  module: {
    rules: [
      {
        mimetype: 'application/json',
        type: 'json',
      },
      {
        test: /\.svg$/,
        loader: 'svg-sprite-loader',
      },
    ],
  },
  plugins: [new SpriteLoaderPlugin()],
};

Please tell us about your environment:

Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

This is very similar to #428 and the fix is also similar. In /lib/utils/get-matched-rule-5.js:

const ruleSetCompiler = new RuleSetCompiler([
  // ...
  new BasicEffectRulePlugin('mimetype'),   // add this
  // ...
]);
jpvanhal commented 3 years ago

Fixed by #460.