chore: add Vercel build configuration

- Introduced a new build script for Vercel in package.json.
- Created a new tsdown configuration file for Vercel deployment.
- Updated tsconfig.json to remove the deprecated vercel.ts file from the include path.
- Added a new server entry point for compatibility with Vercel's deployment.
This commit is contained in:
DIYgod 2025-08-10 18:34:16 +08:00
parent bef0e52883
commit 20b67e1402
No known key found for this signature in database
5 changed files with 23 additions and 3 deletions

5
lib/server.ts Normal file
View File

@ -0,0 +1,5 @@
// This file is for compatibility with Vercel's deployment.
import '@/utils/request-rewriter';
export default (await import('./app-bootstrap')).default;

View File

@ -22,6 +22,7 @@
],
"scripts": {
"build": "tsx scripts/workflow/build-routes.ts && tsdown",
"build:vercel": "tsx scripts/workflow/build-routes.ts && tsdown --config ./tsdown-vercel.config.ts",
"build:docs": "tsx scripts/workflow/build-docs.ts",
"dev": "cross-env NODE_ENV=dev tsx watch --inspect --clear-screen=false lib/index.ts",
"dev:cache": "cross-env NODE_ENV=production tsx watch --clear-screen=false lib/index.ts",

View File

@ -18,6 +18,6 @@
"resolveJsonModule": true,
"isolatedModules": true
},
"include": ["./lib/**/*", "./api/vercel.ts"],
"include": ["./lib/**/*"],
"exclude": ["node_modules", "*.test.*"]
}

10
tsdown-vercel.config.ts Normal file
View File

@ -0,0 +1,10 @@
import { defineConfig } from 'tsdown';
import artTemplatesPlugin from './plugins/rollup-plugin-art-templates.ts';
export default defineConfig({
entry: ['./lib/server.ts'],
minify: true,
shims: true,
clean: true,
plugins: [artTemplatesPlugin()],
});

View File

@ -1,5 +1,9 @@
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"framework": "hono",
"github": { "silent": true },
"routes": [{ "src": "/.*", "dest": "/api/vercel.ts" }]
"buildCommand": "pnpm run build:vercel",
"outputDirectory": "dist",
"github": {
"silent": true
}
}