JetBrains / svg-sprite-loader

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

Exception emitted for every svg #487

Open thany opened 2 years ago

thany commented 2 years ago

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

What is the current behavior?

WARNING in ./src/svg/icon-cart.svg
Module Warning (from ./node_modules/svg-sprite-loader/lib/loader.js):
svg-sprite-loader exception. Some loaders will be applied after svg-sprite-loader in extract mode
 @ ./src/svg/sprite.js 3:0-26

What is the expected behavior? No warning. It works, so why complain?

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.

Piece of webpack config might be relevant:

{
        test: /\.svg$/,
        include: [path.resolve(__dirname, 'src/svg')],
        use: [
          {
            loader: 'svg-sprite-loader',
            options: {
              extract: true,
              spriteFilename: 'svg/renewi.sprite.svg'
            }
          },
        ]
      }

Another issue on this mentioned:

Review your webpack config and check that svg-sprite-loader is the latest applied loader to SVGs.

Not sure if this means latest version or last entry but it is both. So that is NOT the solution.

This is especially weird because in your loader.js, it goes:

if (loaderIndex > 0) {
  this.emitWarning(new Exceptions.RemainingLoadersInExtractModeException());
}

This suggests it wants to be the FIRST entry, not the last (or latest)... But even so, why is this made into a problem in the first place? Why does this plugin need to complain about its position in the configuration??

Please tell us about your environment: