@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.
- package/package.json +1 -1
- package/src/index.ts +24 -10
package/package.json
CHANGED
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
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
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
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
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 === "/") {
|