Skip to content

Commit b9752e8

Browse files
authored
Merge pull request #4 from OnurGvnc/main
run `generateIcons` at startup if sprite.svg does not exist
2 parents db730cf + aa6c94d commit b9752e8

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

src/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,21 @@ 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+
}
158+
},
144159
async watchChange(file, type) {
145160
const inputPath = normalizePath(path.join(cwd ?? process.cwd(), inputDir));
146161
if (file.includes(inputPath) && file.endsWith(".svg") && ["create", "delete"].includes(type.event)) {

0 commit comments

Comments
 (0)