From 1bdd0f67632a0f6f590a14ad8b208f5b8f0742ef Mon Sep 17 00:00:00 2001 From: Alem Tuzlak Date: Thu, 16 May 2024 12:50:36 +0200 Subject: [PATCH] Improvements with v1.1.2 --- package.json | 2 +- src/index.ts | 25 +++++++------------- test-apps/remix-vite/icons/bs.svg | 1 + test-apps/remix-vite/icons/d.svg | 1 - test-apps/remix-vite/icons/de.svg | 2 +- test-apps/remix-vite/public/icons/sprite.svg | 3 ++- test-apps/remix-vite/public/icons/types.ts | 4 ++-- 7 files changed, 16 insertions(+), 22 deletions(-) create mode 100644 test-apps/remix-vite/icons/bs.svg delete mode 100644 test-apps/remix-vite/icons/d.svg diff --git a/package.json b/package.json index 6931efb..57d6d17 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vite-plugin-icons-spritesheet", - "version": "1.1.1", + "version": "1.1.2", "description": "Vite plugin that generates a spritesheet out of your icons.", "main": "./dist/index.js", "module": "./dist/index.mjs", diff --git a/src/index.ts b/src/index.ts index 33f076a..2c3dda9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -86,8 +86,8 @@ async function generateSvgSprite({ }) ); const output = [ - '', - '', + "", + "", "", // for semantics: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/defs ...symbols.filter(Boolean), "", @@ -141,20 +141,13 @@ export const iconsSpritesheet: (args: PluginProps) => Plugin = ({ withTypes, inp apply(config) { return config.mode === "development"; }, - async configResolved(config) { - const outputSvgPath = normalizePath(path.join(cwd ?? process.cwd(), outputDir, fileName ?? "sprite.svg")); - const outputSvgExists = await fs - .access(outputSvgPath, fs.constants.F_OK) - .then(() => true) - .catch(() => false); - if (!outputSvgExists) { - await generateIcons({ - withTypes, - inputDir, - outputDir, - fileName, - }); - } + async configResolved() { + await generateIcons({ + withTypes, + inputDir, + outputDir, + fileName, + }); }, async watchChange(file, type) { const inputPath = normalizePath(path.join(cwd ?? process.cwd(), inputDir)); diff --git a/test-apps/remix-vite/icons/bs.svg b/test-apps/remix-vite/icons/bs.svg new file mode 100644 index 0000000..a37bd67 --- /dev/null +++ b/test-apps/remix-vite/icons/bs.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-apps/remix-vite/icons/d.svg b/test-apps/remix-vite/icons/d.svg deleted file mode 100644 index 7086e85..0000000 --- a/test-apps/remix-vite/icons/d.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/test-apps/remix-vite/icons/de.svg b/test-apps/remix-vite/icons/de.svg index 0519ecb..841eb20 100644 --- a/test-apps/remix-vite/icons/de.svg +++ b/test-apps/remix-vite/icons/de.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/test-apps/remix-vite/public/icons/sprite.svg b/test-apps/remix-vite/public/icons/sprite.svg index 7573540..24f220f 100644 --- a/test-apps/remix-vite/public/icons/sprite.svg +++ b/test-apps/remix-vite/public/icons/sprite.svg @@ -4,8 +4,9 @@ - + + diff --git a/test-apps/remix-vite/public/icons/types.ts b/test-apps/remix-vite/public/icons/types.ts index bc810a9..dd4443f 100644 --- a/test-apps/remix-vite/public/icons/types.ts +++ b/test-apps/remix-vite/public/icons/types.ts @@ -3,16 +3,16 @@ export type IconName = | "Test" | "De" - | "D" | "C" + | "Bs" | "B" | "A" export const iconNames = [ "Test", "De", - "D", "C", + "Bs", "B", "A", ] as const