vite-plugin-svg-spritegen 1.0.0 → 1.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/dist/index.js CHANGED
@@ -74,7 +74,7 @@ const writeSprite = async (spritePath, svgMap) => {
74
74
  const definitions = [];
75
75
  await Promise.all(
76
76
  [...svgMap.values()].map(async (inputConfig) => {
77
- const { svgo: svgo$1, removeAttrs, symbolId, filePath } = inputConfig;
77
+ const { svgo: svgo$1, svgoPlugins = [], removeAttrs, symbolId, filePath } = inputConfig;
78
78
  if (spritePath === filePath) return;
79
79
  let svgContent = await node_fs.promises.readFile(filePath, "utf8");
80
80
  if (svgo$1 !== false) {
@@ -89,7 +89,8 @@ const writeSprite = async (spritePath, svgMap) => {
89
89
  attrs: `(${removeAttrs.join("|")})`
90
90
  }
91
91
  }
92
- ] : []
92
+ ] : [],
93
+ ...svgoPlugins
93
94
  ]
94
95
  }).data;
95
96
  }
@@ -146,6 +147,7 @@ const inputConfigDefaults = {
146
147
  prefix: "",
147
148
  removeAttrs: [],
148
149
  svgo: svgoDefault,
150
+ svgoPlugins: [],
149
151
  getSymbolId: (config) => config.prefix + config.matchPath.replace(/\.[^/.]+$/, "").replaceAll("/", "-").toLowerCase()
150
152
  };
151
153
  const stripUnusedDefaults = {
package/dist/index.mjs CHANGED
@@ -72,7 +72,7 @@ const writeSprite = async (spritePath, svgMap) => {
72
72
  const definitions = [];
73
73
  await Promise.all(
74
74
  [...svgMap.values()].map(async (inputConfig) => {
75
- const { svgo, removeAttrs, symbolId, filePath } = inputConfig;
75
+ const { svgo, svgoPlugins = [], removeAttrs, symbolId, filePath } = inputConfig;
76
76
  if (spritePath === filePath) return;
77
77
  let svgContent = await promises.readFile(filePath, "utf8");
78
78
  if (svgo !== false) {
@@ -87,7 +87,8 @@ const writeSprite = async (spritePath, svgMap) => {
87
87
  attrs: `(${removeAttrs.join("|")})`
88
88
  }
89
89
  }
90
- ] : []
90
+ ] : [],
91
+ ...svgoPlugins
91
92
  ]
92
93
  }).data;
93
94
  }
@@ -144,6 +145,7 @@ const inputConfigDefaults = {
144
145
  prefix: "",
145
146
  removeAttrs: [],
146
147
  svgo: svgoDefault,
148
+ svgoPlugins: [],
147
149
  getSymbolId: (config) => config.prefix + config.matchPath.replace(/\.[^/.]+$/, "").replaceAll("/", "-").toLowerCase()
148
150
  };
149
151
  const stripUnusedDefaults = {
package/dist/types.d.ts CHANGED
@@ -6,6 +6,7 @@ export interface InputConfig {
6
6
  prefix?: string;
7
7
  getSymbolId?: (config: Omit<ResolvedInputConfig, 'symbolId'>) => string;
8
8
  removeAttrs?: string[];
9
+ svgoPlugins?: SvgoConfig['plugins'];
9
10
  svgo?: SvgoConfig | false;
10
11
  }
11
12
  export interface ResolvedInputConfig extends Required<InputConfig> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-svg-spritegen",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "Vite plugin that generates an svg spritesheet, optionally removing unused svg files.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",