vite-plugin-svg-spritegen 1.2.0 → 1.2.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 +9 -8
- package/dist/index.mjs +9 -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,17 @@ 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
|
-
|
|
226
|
-
|
|
227
|
-
|
|
224
|
+
matches.push(...stripUnusedResolved.whitelist);
|
|
225
|
+
console.log(matches);
|
|
226
|
+
for (const match of matches) {
|
|
227
|
+
if (referencedSvgFiles.has(match)) continue;
|
|
228
|
+
const svgPath = allSvgFiles.get(match);
|
|
228
229
|
if (!svgPath) continue;
|
|
229
|
-
referencedSvgFiles.set(
|
|
230
|
+
referencedSvgFiles.set(match, svgPath);
|
|
230
231
|
}
|
|
231
232
|
},
|
|
232
233
|
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,17 @@ 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
|
-
|
|
224
|
-
|
|
225
|
-
|
|
222
|
+
matches.push(...stripUnusedResolved.whitelist);
|
|
223
|
+
console.log(matches);
|
|
224
|
+
for (const match of matches) {
|
|
225
|
+
if (referencedSvgFiles.has(match)) continue;
|
|
226
|
+
const svgPath = allSvgFiles.get(match);
|
|
226
227
|
if (!svgPath) continue;
|
|
227
|
-
referencedSvgFiles.set(
|
|
228
|
+
referencedSvgFiles.set(match, svgPath);
|
|
228
229
|
}
|
|
229
230
|
},
|
|
230
231
|
async generateBundle(_options, bundle) {
|
package/package.json
CHANGED