Skip to content

Commit 1bdd0f6

Browse files
committed
Improvements with v1.1.2
1 parent b9752e8 commit 1bdd0f6

7 files changed

Lines changed: 16 additions & 22 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vite-plugin-icons-spritesheet",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"description": "Vite plugin that generates a spritesheet out of your icons.",
55
"main": "./dist/index.js",
66
"module": "./dist/index.mjs",

src/index.ts

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ async function generateSvgSprite({
8686
})
8787
);
8888
const output = [
89-
'<?xml version="1.0" encoding="UTF-8"?>',
90-
'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="0" height="0">',
89+
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
90+
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"0\" height=\"0\">",
9191
"<defs>", // for semantics: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/defs
9292
...symbols.filter(Boolean),
9393
"</defs>",
@@ -141,20 +141,13 @@ export const iconsSpritesheet: (args: PluginProps) => Plugin = ({ withTypes, inp
141141
apply(config) {
142142
return config.mode === "development";
143143
},
144-
async configResolved(config) {
145-
const outputSvgPath = normalizePath(path.join(cwd ?? process.cwd(), outputDir, fileName ?? "sprite.svg"));
146-
const outputSvgExists = await fs
147-
.access(outputSvgPath, fs.constants.F_OK)
148-
.then(() => true)
149-
.catch(() => false);
150-
if (!outputSvgExists) {
151-
await generateIcons({
152-
withTypes,
153-
inputDir,
154-
outputDir,
155-
fileName,
156-
});
157-
}
144+
async configResolved() {
145+
await generateIcons({
146+
withTypes,
147+
inputDir,
148+
outputDir,
149+
fileName,
150+
});
158151
},
159152
async watchChange(file, type) {
160153
const inputPath = normalizePath(path.join(cwd ?? process.cwd(), inputDir));

test-apps/remix-vite/icons/bs.svg

Lines changed: 1 addition & 0 deletions
Loading

test-apps/remix-vite/icons/d.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

test-apps/remix-vite/icons/de.svg

Lines changed: 1 addition & 1 deletion
Loading

test-apps/remix-vite/public/icons/sprite.svg

Lines changed: 2 additions & 1 deletion
Loading

test-apps/remix-vite/public/icons/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
export type IconName =
44
| "Test"
55
| "De"
6-
| "D"
76
| "C"
7+
| "Bs"
88
| "B"
99
| "A"
1010

1111
export const iconNames = [
1212
"Test",
1313
"De",
14-
"D",
1514
"C",
15+
"Bs",
1616
"B",
1717
"A",
1818
] as const

0 commit comments

Comments
 (0)