Own watcher
This commit is contained in:
parent
f850d75503
commit
01ad78eb74
19
bin/watch.ts
Normal file
19
bin/watch.ts
Normal 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
1
package-lock.json
generated
|
@ -10,6 +10,7 @@
|
|||
"dependencies": {
|
||||
"@mapbox/rehype-prism": "^0.9.0",
|
||||
"asciidoctor": "^3.0.4",
|
||||
"chokidar": "^3.6.0",
|
||||
"cssnano": "^7.0.2",
|
||||
"glob": "^10.4.2",
|
||||
"gulp": "^5.0.0",
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
"dependencies": {
|
||||
"@mapbox/rehype-prism": "^0.9.0",
|
||||
"asciidoctor": "^3.0.4",
|
||||
"chokidar": "^3.6.0",
|
||||
"cssnano": "^7.0.2",
|
||||
"glob": "^10.4.2",
|
||||
"gulp": "^5.0.0",
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
"compilerOptions": {
|
||||
"esModuleInterop": true,
|
||||
"jsx": "react-jsx",
|
||||
"jsxImportSource": "preact"
|
||||
"jsxImportSource": "preact",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user