-
Notifications
You must be signed in to change notification settings - Fork 340
/
clean.ts
17 lines (15 loc) · 630 Bytes
/
clean.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import fs from "fs";
import path from "path";
// Clean output directory, or create build directory
const outDir = path.resolve(process.cwd(), "dist");
if (fs.existsSync(outDir)) {
const filesToClean = fs.readdirSync(outDir).map((dirName) => path.resolve(outDir, dirName));
for (const file of filesToClean) {
fs.rmSync(file, { recursive: true });
}
} else {
fs.mkdirSync(outDir);
}
// Delete static/packs dir to prevent overwrite during rebuilds (temporary backwards compatibility)
const oldPacksDir = path.resolve(process.cwd(), "static/packs");
fs.rmSync(oldPacksDir, { recursive: true, force: true });