vite-plugin-svg-spritegen 1.2.0 → 1.2.2

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
@@ -141,7 +141,7 @@ const svgoDefault = {
141
141
  }
142
142
  ]
143
143
  };
144
- const defaultMatchPattern = /:\s*(?:"|'|`)(?<icon>.+?)(?:"|'|`)/g;
144
+ const defaultMatchPattern = /(?:(?:name)|(?:iconName)|(?:icon)): "(?<icon>.+?)"/g;
145
145
  const inputConfigDefaults = {
146
146
  pattern: "**/*.svg",
147
147
  baseDir: "./",
@@ -217,16 +217,16 @@ function svgSpritegen(config) {
217
217
  },
218
218
  moduleParsed(info) {
219
219
  if (!isBuild || !stripUnusedResolved.enabled || !srcFilter(info.id) || !info.code) return;
220
- const matchPattern = config.matchPattern ? new RegExp(config.matchPattern) : defaultMatchPattern;
221
- const icons = [...info.code.matchAll(matchPattern)].flatMap(
220
+ const matchPattern = config.matchPattern ? new RegExp(config.matchPattern, "g") : defaultMatchPattern;
221
+ const matches = [...info.code.matchAll(matchPattern)].flatMap(
222
222
  ({ groups }) => (groups == null ? void 0 : groups.icon) ?? []
223
223
  );
224
- icons.push(...stripUnusedResolved.whitelist);
225
- for (const icon of icons) {
226
- if (!referencedSvgFiles.has(icon)) continue;
227
- const svgPath = allSvgFiles.get(icon);
224
+ matches.push(...stripUnusedResolved.whitelist);
225
+ for (const match of matches) {
226
+ if (referencedSvgFiles.has(match)) continue;
227
+ const svgPath = allSvgFiles.get(match);
228
228
  if (!svgPath) continue;
229
- referencedSvgFiles.set(icon, svgPath);
229
+ referencedSvgFiles.set(match, svgPath);
230
230
  }
231
231
  },
232
232
  async generateBundle(_options, bundle) {
package/dist/index.mjs CHANGED
@@ -139,7 +139,7 @@ const svgoDefault = {
139
139
  }
140
140
  ]
141
141
  };
142
- const defaultMatchPattern = /:\s*(?:"|'|`)(?<icon>.+?)(?:"|'|`)/g;
142
+ const defaultMatchPattern = /(?:(?:name)|(?:iconName)|(?:icon)): "(?<icon>.+?)"/g;
143
143
  const inputConfigDefaults = {
144
144
  pattern: "**/*.svg",
145
145
  baseDir: "./",
@@ -215,16 +215,16 @@ function svgSpritegen(config) {
215
215
  },
216
216
  moduleParsed(info) {
217
217
  if (!isBuild || !stripUnusedResolved.enabled || !srcFilter(info.id) || !info.code) return;
218
- const matchPattern = config.matchPattern ? new RegExp(config.matchPattern) : defaultMatchPattern;
219
- const icons = [...info.code.matchAll(matchPattern)].flatMap(
218
+ const matchPattern = config.matchPattern ? new RegExp(config.matchPattern, "g") : defaultMatchPattern;
219
+ const matches = [...info.code.matchAll(matchPattern)].flatMap(
220
220
  ({ groups }) => (groups == null ? void 0 : groups.icon) ?? []
221
221
  );
222
- icons.push(...stripUnusedResolved.whitelist);
223
- for (const icon of icons) {
224
- if (!referencedSvgFiles.has(icon)) continue;
225
- const svgPath = allSvgFiles.get(icon);
222
+ matches.push(...stripUnusedResolved.whitelist);
223
+ for (const match of matches) {
224
+ if (referencedSvgFiles.has(match)) continue;
225
+ const svgPath = allSvgFiles.get(match);
226
226
  if (!svgPath) continue;
227
- referencedSvgFiles.set(icon, svgPath);
227
+ referencedSvgFiles.set(match, svgPath);
228
228
  }
229
229
  },
230
230
  async generateBundle(_options, bundle) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-svg-spritegen",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
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",