Skip to content

Commit

Permalink
buid: fix deploy on vercel
Browse files Browse the repository at this point in the history
  • Loading branch information
Chilfish committed Mar 15, 2024
1 parent 5bcb42e commit bb89680
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .vercelignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
.husky
.vscode
node_modules
scripts
CHANGELOG.md
README.md
dist

*.log
.output
Expand Down
Empty file added api/index.cjs
Empty file.
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "hono-ncm",
"type": "module",
"version": "0.0.1",
"private": true,
"packageManager": "pnpm@8.15.4",
Expand All @@ -26,10 +25,10 @@
],
"scripts": {
"dev": "tsx watch --no-cache src/node.ts",
"build": "unbuild",
"build": "tsx scripts/build.ts",
"start": "tsx src/node.ts",
"prepare": "husky",
"lint": "eslint . --fix"
"prepare": "husky || true && pnpm build",
"lint": "eslint ."
},
"dependencies": {
"hono": "^4.1.0"
Expand Down
12 changes: 12 additions & 0 deletions scripts/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { copyFileSync } from 'node:fs'
import { join, resolve } from 'node:path'
import { execSync } from 'node:child_process'

const root = resolve()

execSync('pnpm unbuild', { stdio: 'inherit' })

copyFileSync(
join(root, 'dist', 'index.cjs'),
join(root, 'api', 'index.cjs'),
)
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"esModuleInterop": true
},
"include": [
"./src/**/*",
"./src/**/*"
],
"exclude": [
"node_modules",
Expand Down
4 changes: 2 additions & 2 deletions vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
"version": 2,
"builds": [
{
"src": "./dist/index.cjs",
"src": "./api/index.cjs",
"use": "@vercel/node"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "/dist/index.cjs"
"dest": "/api/index.cjs"
}
]
}

0 comments on commit bb89680

Please sign in to comment.