Own watcher

This commit is contained in:
Thibault “Adædra” Hamel 2024-06-27 04:58:26 +02:00
parent f850d75503
commit 01ad78eb74
4 changed files with 24 additions and 1 deletions

19
bin/watch.ts Normal file
View File

@ -0,0 +1,19 @@
import { Worker } from "node:worker_threads";
import chokidar from "chokidar";
const watch = (glob: string | string[], task: string) =>
chokidar.watch(glob).on("change", (path: string) => {
console.log("[change]", path, "->", task);
return new Promise<void>((resolve) => {
const worker = new Worker(new URL(import.meta.resolve("./build.ts")), { argv: [task] });
worker.on("exit", () => resolve());
});
});
watch(["lib/views/*.tsx", "articles/**/*.asciidoc"], "articles");
watch("src/*.css", "css");
watch("src/*.avif", "images");
watch("src/*.svg", "svg");
watch("dist/_assets/fonts.manifest", "css");
watch("dist/_assets/css.manifest", "articles");

1
package-lock.json generated
View File

@ -10,6 +10,7 @@
"dependencies": { "dependencies": {
"@mapbox/rehype-prism": "^0.9.0", "@mapbox/rehype-prism": "^0.9.0",
"asciidoctor": "^3.0.4", "asciidoctor": "^3.0.4",
"chokidar": "^3.6.0",
"cssnano": "^7.0.2", "cssnano": "^7.0.2",
"glob": "^10.4.2", "glob": "^10.4.2",
"gulp": "^5.0.0", "gulp": "^5.0.0",

View File

@ -6,6 +6,7 @@
"dependencies": { "dependencies": {
"@mapbox/rehype-prism": "^0.9.0", "@mapbox/rehype-prism": "^0.9.0",
"asciidoctor": "^3.0.4", "asciidoctor": "^3.0.4",
"chokidar": "^3.6.0",
"cssnano": "^7.0.2", "cssnano": "^7.0.2",
"glob": "^10.4.2", "glob": "^10.4.2",
"gulp": "^5.0.0", "gulp": "^5.0.0",

View File

@ -8,6 +8,8 @@
"compilerOptions": { "compilerOptions": {
"esModuleInterop": true, "esModuleInterop": true,
"jsx": "react-jsx", "jsx": "react-jsx",
"jsxImportSource": "preact" "jsxImportSource": "preact",
"module": "NodeNext",
"moduleResolution": "NodeNext"
} }
} }