Notes/bin/watch-dist.ts
2025-01-09 18:07:02 +02:00

17 lines
460 B
TypeScript

import chokidar from "chokidar";
import fs from "fs";
import path from "path";
const emptyCallback = () => {};
function onFileChanged(sourceFile: string) {
const destFile = path.join("dist", sourceFile);
console.log(`${sourceFile} -> ${destFile}`);
fs.copyFile(sourceFile, destFile, emptyCallback);
}
const sourceDir = "src/public";
chokidar.watch(sourceDir).on("change", onFileChanged);
console.log(`Watching for changes to ${sourceDir}...`);