Notes/bin/watch-dist.ts

18 lines
469 B
TypeScript
Raw Normal View History

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}...`);