svg-sprite-loader
svg-sprite-loader copied to clipboard
sprite loader doesn't work with multiple loaders (having multiple in- and outputs): all svg's go into first sprite
Do you want to request a feature, report a bug or ask a question? Report a bug
What is the current behavior? When adding the loader multiple times on different in- and outputs all sprites get added to the first file and the second sprite file isn't created.
What is the expected behavior? All sprites from source A rendered to sprite A and all sprites from source B rendered to sprite B.
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 part on svg-sprite-loader:
const SVGSpriteLoaderPlugin = require('svg-sprite-loader/plugin');
// ...
const svgSprites = ['sprite-a', 'sprite-b'];
for (let i = 0; i < svgSprites.length; i++) {
const folderName = svgSprites[i];
const spritesSource = path.resolve(paths.src, `assets/svg-sprites/${folderName}`);
const relSpriteFilename = `assets/img/${folderName}.svg`;
config.module.rules.push({
test: /\.(svg)(\?[a-z0-9=.]+)?$/,
include: spritesSource,
use: [{
loader: 'svg-sprite-loader',
options: {
extract: true,
spriteFilename: relSpriteFilename,
},
}],
});
}
// ...
config.plugins.push(new SVGSpriteLoaderPlugin({ plainSprite: false }));
// ...
Please tell us about your environment:
- Node.js version: 14.15.3
- webpack version: 4.44.2
- svg-sprite-loader version: 5.0.0
- OS type & version: Windows 10