astro-icon
Advanced tools
Comparing version 1.1.4 to 1.1.5
@@ -0,5 +1,6 @@ | ||
import { createHash } from "node:crypto"; | ||
import { parse, resolve } from "node:path"; | ||
import { mkdir, readFile, writeFile } from "node:fs/promises"; | ||
import loadLocalCollection from "./loaders/loadLocalCollection.js"; | ||
import loadIconifyCollections from "./loaders/loadIconifyCollections.js"; | ||
import { createHash } from "node:crypto"; | ||
export function createPlugin({ include = {}, iconDir = "src/icons", svgoOptions }, ctx) { | ||
@@ -36,3 +37,10 @@ let collections; | ||
watcher.add(`${iconDir}/**/*.svg`); | ||
watcher.on("change", async () => { | ||
watcher.on("all", async (_, filepath) => { | ||
const parsedPath = parse(filepath); | ||
const resolvedIconDir = resolve(root.pathname, iconDir); | ||
const isSvgFileInIconDir = parsedPath.dir.startsWith(resolvedIconDir) && | ||
parsedPath.ext === ".svg"; | ||
const isAstroConfig = parsedPath.name === "astro.config"; | ||
if (!isSvgFileInIconDir && !isAstroConfig) | ||
return; | ||
console.log(`Local icons changed, reloading`); | ||
@@ -39,0 +47,0 @@ try { |
{ | ||
"name": "astro-icon", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "types": "./dist/index.d.ts", |
28546
339