Skip to content

Commit

Permalink
Merge pull request #4 from OnurGvnc/main
Browse files Browse the repository at this point in the history
run `generateIcons` at startup if sprite.svg does not exist
  • Loading branch information
AlemTuzlak authored May 16, 2024
2 parents db730cf + aa6c94d commit b9752e8
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,21 @@ 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 watchChange(file, type) {
const inputPath = normalizePath(path.join(cwd ?? process.cwd(), inputDir));
if (file.includes(inputPath) && file.endsWith(".svg") && ["create", "delete"].includes(type.event)) {
Expand Down

0 comments on commit b9752e8

Please sign in to comment.