From fd98be10279cb31fefc9d4155324cfe7f0480573 Mon Sep 17 00:00:00 2001 From: Stephen Zhou <38493346+hyoban@users.noreply.github.com> Date: Mon, 8 Dec 2025 00:21:14 +0800 Subject: [PATCH] chore: fix art template on vercel (#20647) --- lib/routes/hupu/all.ts | 2 +- package.json | 2 +- tsdown-vercel.config.ts | 3 +++ vercel.json | 8 ++++++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/routes/hupu/all.ts b/lib/routes/hupu/all.ts index 041268ac92..a49fc1e7bd 100644 --- a/lib/routes/hupu/all.ts +++ b/lib/routes/hupu/all.ts @@ -83,7 +83,7 @@ async function handler(ctx) { item.author = content('.bbs-user-wrapper-content-name-span').first().text(); item.pubDate = item.pubDate ?? timezone(parseRelativeDate(content('.second-line-user-info').first().text()), +8); - item.description = art(path.join(__dirname, 'templates/description.art'), { + item.description = art(path.resolve(__dirname, 'templates/description.art'), { videos, description: content('.bbs-content').first().html(), }); diff --git a/package.json b/package.json index 2bc1700f37..69ef31b75d 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "build:docs": "npm run build:routes && tsx scripts/workflow/build-docs.ts", "build:lib": "npm run build:routes && tsdown --config ./tsdown-lib.config.ts", "build:routes": "cross-env NODE_ENV=dev tsx scripts/workflow/build-routes.ts", - "build:vercel": "npm run build:routes && tsdown --config ./tsdown-vercel.config.ts && mv dist/server.mjs dist/index.mjs", + "vercel-build": "npm run build:routes && tsdown --config ./tsdown-vercel.config.ts", "dev": "cross-env NODE_ENV=dev NODE_OPTIONS='--max-http-header-size=32768' tsx watch --inspect --clear-screen=false lib/index.ts", "dev:cache": "cross-env NODE_ENV=production NODE_OPTIONS='--max-http-header-size=32768' tsx watch --clear-screen=false lib/index.ts", "format": "eslint --cache --fix \"**/*.{ts,tsx,js,yml}\" --concurrency auto && prettier . --write --experimental-cli", diff --git a/tsdown-vercel.config.ts b/tsdown-vercel.config.ts index 6ff4290706..d78e2f3952 100644 --- a/tsdown-vercel.config.ts +++ b/tsdown-vercel.config.ts @@ -4,6 +4,9 @@ import artTemplatesPlugin from './plugins/rollup-plugin-art-templates.ts'; export default defineConfig({ entry: ['./lib/server.ts'], + // Wait for https://github.com/vercel/vercel/pull/14429 + // Then we can set outDir to outputDirectory in vercel.json + outDir: 'src', minify: true, shims: true, clean: true, diff --git a/vercel.json b/vercel.json index 4b5f47c0d0..eb08b034f8 100644 --- a/vercel.json +++ b/vercel.json @@ -1,8 +1,12 @@ { "$schema": "https://openapi.vercel.sh/vercel.json", "framework": "hono", - "buildCommand": "pnpm run build:vercel", - "outputDirectory": "dist", + "outputDirectory": "src", + "functions": { + "src/server.mjs": { + "includeFiles": "./src/templates/**/*.art" + } + }, "rewrites": [ { "source": "/favicon.ico",