@timber-js/app 0.2.0-alpha.150 → 0.2.0-alpha.151
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/dist/index.js +23 -1
- package/dist/index.js.map +1 -1
- package/dist/plugins/dev-server.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/plugins/dev-server.ts +30 -1
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { t as formatSize } from "./_chunks/format-CfwjgPz9.js";
|
|
|
9
9
|
import { basename, dirname, extname, join, normalize, relative, resolve, win32 } from "node:path";
|
|
10
10
|
import { builtinModules, createRequire } from "node:module";
|
|
11
11
|
import react, { reactCompilerPreset } from "@vitejs/plugin-react";
|
|
12
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
12
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
13
13
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
14
14
|
import { constants, createGzip, gzipSync } from "node:zlib";
|
|
15
15
|
import { Readable, pipeline } from "node:stream";
|
|
@@ -1478,6 +1478,10 @@ function createTimberMiddleware(server, ctx) {
|
|
|
1478
1478
|
next();
|
|
1479
1479
|
return;
|
|
1480
1480
|
}
|
|
1481
|
+
if (isPublicFile(server, url)) {
|
|
1482
|
+
next();
|
|
1483
|
+
return;
|
|
1484
|
+
}
|
|
1481
1485
|
if (isAssetRequest(url) && !isMetadataRouteServePath(url) && !isRouteOwnedAsset(ctx.routeTree, server, url)) {
|
|
1482
1486
|
next();
|
|
1483
1487
|
return;
|
|
@@ -1661,6 +1665,24 @@ function isAssetRequest(url) {
|
|
|
1661
1665
|
return ASSET_EXTENSIONS.test(url);
|
|
1662
1666
|
}
|
|
1663
1667
|
/**
|
|
1668
|
+
* Check if a URL maps to a real file in the project's public/ directory.
|
|
1669
|
+
* Vite serves public/ files as static assets — if a file exists there it
|
|
1670
|
+
* must be passed through to Vite regardless of extension.
|
|
1671
|
+
*/
|
|
1672
|
+
function isPublicFile(server, url) {
|
|
1673
|
+
const { publicDir } = server.config;
|
|
1674
|
+
if (!publicDir) return false;
|
|
1675
|
+
const pathname = url.split("?")[0];
|
|
1676
|
+
const relativePath = pathname.startsWith("/") ? pathname.slice(1) : pathname;
|
|
1677
|
+
if (!relativePath) return false;
|
|
1678
|
+
const fullPath = join(publicDir, relativePath);
|
|
1679
|
+
try {
|
|
1680
|
+
return statSync(fullPath).isFile();
|
|
1681
|
+
} catch {
|
|
1682
|
+
return false;
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
/**
|
|
1664
1686
|
* Check whether an asset-extension URL belongs to a scanned route rather
|
|
1665
1687
|
* than a static file.
|
|
1666
1688
|
*
|