diff --git a/package.json b/package.json
index 0a7bcf2..6931efb 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "vite-plugin-icons-spritesheet",
- "version": "1.1.0",
+ "version": "1.1.1",
"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 ffbb588..3ed3065 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -123,8 +123,14 @@ async function generateTypes({ names, outputPath }: { names: string[]; outputPat
* so only write if the content has changed
*/
async function writeIfChanged(filepath: string, newContent: string, message: string) {
- const currentContent = await fs.readFile(filepath, "utf8");
- if (currentContent !== newContent) {
+ try {
+ const currentContent = await fs.readFile(filepath, "utf8");
+ if (currentContent !== newContent) {
+ await fs.writeFile(filepath, newContent, "utf8");
+ console.log(message);
+ }
+ } catch (e) {
+ // File doesn't exist yet
await fs.writeFile(filepath, newContent, "utf8");
console.log(message);
}
diff --git a/test-apps/remix-vite/icons/b.svg b/test-apps/remix-vite/icons/b.svg
index 7086e85..55076af 100644
--- a/test-apps/remix-vite/icons/b.svg
+++ b/test-apps/remix-vite/icons/b.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/test-apps/remix-vite/icons/c.svg b/test-apps/remix-vite/icons/c.svg
index dc1ced5..55076af 100644
--- a/test-apps/remix-vite/icons/c.svg
+++ b/test-apps/remix-vite/icons/c.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ 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 e69de29..0519ecb 100644
--- a/test-apps/remix-vite/icons/de.svg
+++ b/test-apps/remix-vite/icons/de.svg
@@ -0,0 +1 @@
+
\ No newline at end of file