Skip to content

Commit 370ac2e

Browse files
committed
Try to fix Vercel build
1 parent 16b194e commit 370ac2e

File tree

4 files changed

+29
-16
lines changed

4 files changed

+29
-16
lines changed

next.config.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

scripts/build-vercel.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { $ } from "bun";
2+
import { cp, mkdir } from "fs/promises";
3+
import { resolve } from "path";
4+
5+
const rootDir = resolve(import.meta.dir, "..");
6+
const publicDir = resolve(rootDir, "public");
7+
8+
// Clean and create public directory
9+
await $`rm -rf ${publicDir}`;
10+
await mkdir(publicDir, { recursive: true });
11+
12+
// Build browser files
13+
console.log("Building browser...");
14+
await import("./build-browser.ts");
15+
16+
// Copy browser build to public
17+
await cp(resolve(rootDir, "dist/browser"), publicDir, { recursive: true });
18+
console.log("Copied browser files to public/");
19+
20+
// Copy src directory for Vercel's Hono detection
21+
await mkdir(resolve(publicDir, "src"), { recursive: true });
22+
await cp(resolve(rootDir, "src/index.ts"), resolve(publicDir, "src/index.ts"));
23+
await cp(resolve(rootDir, "src/api"), resolve(publicDir, "src/api"), { recursive: true });
24+
console.log("Copied server source to public/src/");
25+
26+
console.log("✅ Vercel build complete: public/");

src/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,5 @@ const app = new Hono();
66
// API routes
77
app.route("/", api);
88

9-
// Static files and SPA fallback handled by Vercel via public/ directory and rewrites
10-
// This file is the API entry point for Vercel's backend detection
11-
129
export default app;
10+

vercel.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
{
22
"$schema": "https://openapi.vercel.sh/vercel.json",
33
"installCommand": "bun install",
4-
"buildCommand": "bun run build:browser && mkdir -p public && cp -r dist/browser/* public/",
5-
"outputDirectory": "public",
6-
"rewrites": [
7-
{ "source": "/api/:path*", "destination": "/api/:path*" },
8-
{ "source": "/((?!api/).*)", "destination": "/index.html" }
9-
]
4+
"buildCommand": "bun run ./scripts/build-vercel.ts",
5+
"outputDirectory": "public"
106
}

0 commit comments

Comments
 (0)