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 +8 -8
- package/dist/index.mjs +8 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -141,7 +141,7 @@ const svgoDefault = {
|
|
|
141
141
|
}
|
|
142
142
|
]
|
|
143
143
|
};
|
|
144
|
-
const defaultMatchPattern =
|
|
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
|
|
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
|
-
|
|
225
|
-
for (const
|
|
226
|
-
if (
|
|
227
|
-
const svgPath = allSvgFiles.get(
|
|
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(
|
|
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 =
|
|
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
|
|
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
|
-
|
|
223
|
-
for (const
|
|
224
|
-
if (
|
|
225
|
-
const svgPath = allSvgFiles.get(
|
|
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(
|
|
227
|
+
referencedSvgFiles.set(match, svgPath);
|
|
228
228
|
}
|
|
229
229
|
},
|
|
230
230
|
async generateBundle(_options, bundle) {
|
package/package.json
CHANGED