@jsnchn/buntastic 0.0.10 → 0.0.12

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.ts +24 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsnchn/buntastic",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "A simple static site generator built with Bun",
5
5
  "type": "module",
6
6
  "bin": {
package/src/index.ts CHANGED
@@ -289,11 +289,14 @@ async function dev(): Promise<void> {
289
289
  const distPath = join(DIST_DIR, path);
290
290
 
291
291
  if (await exists(distPath)) {
292
- const file = Bun.file(distPath);
293
- const mimeType = getMimeType(distPath);
294
- return new Response(file, {
295
- headers: { "Content-Type": mimeType },
296
- });
292
+ const stat = await import("fs").then(fs => fs.statSync(distPath));
293
+ if (stat.isFile()) {
294
+ const file = Bun.file(distPath);
295
+ const mimeType = getMimeType(distPath);
296
+ return new Response(file, {
297
+ headers: { "Content-Type": mimeType },
298
+ });
299
+ }
297
300
  }
298
301
 
299
302
  if (path === "/") {
@@ -353,6 +356,14 @@ async function dev(): Promise<void> {
353
356
  fsWatch(dir, { recursive: true }, (eventType, filename) => {
354
357
  if (!filename) return;
355
358
  if (filename.endsWith("~") || filename.startsWith(".")) return;
359
+
360
+ if (dir === PUBLIC_DIR) {
361
+ const ext = filename.split(".").pop()?.toLowerCase();
362
+ if (ext && !["css", "js", "ts", "mjs"].includes(ext)) {
363
+ return;
364
+ }
365
+ }
366
+
356
367
  console.log(`[${eventType}] ${filename} - rebuilding...`);
357
368
  scheduleBuild();
358
369
  });
@@ -372,11 +383,14 @@ async function preview(): Promise<void> {
372
383
  const distPath = join(DIST_DIR, path);
373
384
 
374
385
  if (await exists(distPath)) {
375
- const file = Bun.file(distPath);
376
- const mimeType = getMimeType(distPath);
377
- return new Response(file, {
378
- headers: { "Content-Type": mimeType },
379
- });
386
+ const stat = await import("fs").then(fs => fs.statSync(distPath));
387
+ if (stat.isFile()) {
388
+ const file = Bun.file(distPath);
389
+ const mimeType = getMimeType(distPath);
390
+ return new Response(file, {
391
+ headers: { "Content-Type": mimeType },
392
+ });
393
+ }
380
394
  }
381
395
 
382
396
  if (path === "/") {