@jsnchn/buntastic 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.ts +28 -5
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { mkdir, writeFile, readFile, copyFile, exists } from "fs/promises";
|
|
2
|
+
import { watch as fsWatch } from "fs/promises";
|
|
2
3
|
import { join, relative, dirname, extname } from "path";
|
|
3
4
|
import { Glob } from "bun";
|
|
4
5
|
|
|
@@ -291,11 +292,33 @@ async function dev(): Promise<void> {
|
|
|
291
292
|
|
|
292
293
|
console.log(`Dev server running at http://localhost:${server.port}`);
|
|
293
294
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}
|
|
295
|
+
await build(false);
|
|
296
|
+
|
|
297
|
+
const watcher1 = fsWatch(CONTENT_DIR, { recursive: true });
|
|
298
|
+
const watcher2 = fsWatch(LAYOUTS_DIR, { recursive: true });
|
|
299
|
+
const watcher3 = fsWatch(PUBLIC_DIR, { recursive: true });
|
|
300
|
+
|
|
301
|
+
const watchers = [watcher1, watcher2, watcher3];
|
|
302
|
+
|
|
303
|
+
let debounceTimer: ReturnType<typeof setTimeout> | undefined;
|
|
304
|
+
const rebuild = () => {
|
|
305
|
+
clearTimeout(debounceTimer);
|
|
306
|
+
debounceTimer = setTimeout(async () => {
|
|
307
|
+
console.log("Rebuilding...");
|
|
308
|
+
await build(false);
|
|
309
|
+
}, 100);
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
(async () => {
|
|
313
|
+
for (const watcher of watchers) {
|
|
314
|
+
(async () => {
|
|
315
|
+
for await (const event of watcher) {
|
|
316
|
+
console.log(`[${event.eventType}] ${event.filename} - rebuilding...`);
|
|
317
|
+
rebuild();
|
|
318
|
+
}
|
|
319
|
+
})();
|
|
320
|
+
}
|
|
321
|
+
})();
|
|
299
322
|
}
|
|
300
323
|
|
|
301
324
|
async function preview(): Promise<void> {
|