svg-sprite-generation-loader 2.0.18 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svg-sprite-generation-loader",
3
- "version": "2.0.18",
3
+ "version": "2.1.1",
4
4
  "description": "Webpack loader for generating external svg symbol sprite files",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/plugin.js CHANGED
@@ -1,6 +1,10 @@
1
1
  const svgSpriteState = require('./utils/spriteState');
2
2
 
3
3
  class SvgSpriteGeneratorPlugin {
4
+ constructor(params) {
5
+ this.params = params;
6
+ }
7
+
4
8
  // eslint-disable-next-line class-methods-use-this
5
9
  apply(compiler) {
6
10
  // webpack module instance can be accessed from the compiler object,
@@ -22,7 +26,7 @@ class SvgSpriteGeneratorPlugin {
22
26
  Object.keys(svgSpriteState.sprites).forEach((spriteFilePath) => {
23
27
  compilation.emitAsset(
24
28
  spriteFilePath,
25
- new RawSource(svgSpriteState.getSpriteContent(spriteFilePath))
29
+ new RawSource(svgSpriteState.getSpriteContent(spriteFilePath, this.params))
26
30
  );
27
31
  });
28
32
  }
@@ -8,10 +8,10 @@ class SvgSpriteGenerationState {
8
8
  this.sprites[spriteFilePath][icon.symbolId] = icon;
9
9
  }
10
10
 
11
- getSpriteContent(spriteFilePath) {
11
+ getSpriteContent(spriteFilePath, options = {}) {
12
12
  return `${Object.keys(this.sprites[spriteFilePath]).reduce(
13
13
  (result, iconId) =>
14
- `${result}<symbol viewBox="${this.sprites[spriteFilePath][iconId].attributes.viewBox}" fill="none" id="${iconId}">${this.sprites[spriteFilePath][iconId].content}</symbol>`,
14
+ `${result}<symbol viewBox="${this.sprites[spriteFilePath][iconId].attributes.viewBox}"${options.unsetSymbolFill ? '' : ' fill="none"'} id="${iconId}">${this.sprites[spriteFilePath][iconId].content}</symbol>`,
15
15
  '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">'
16
16
  )}</svg>`;
17
17
  }