feat: add build:serve script and update build:web command for server serving, fixed #147

Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
Innei
2025-11-06 01:15:34 +08:00
parent bc4cd36233
commit c1d585d9ac
3 changed files with 6 additions and 6 deletions

View File

@@ -10,6 +10,7 @@
"scripts": {
"analyze": "analyzer=1 vite build",
"build": "tsx scripts/build.ts",
"build:serve": "BUILD_FOR_SERVER_SERVE=1 vite build",
"dev": "tsx scripts/dev.ts",
"format": "prettier --write \"src/**/*.ts\" ",
"lint": "eslint --fix",
@@ -109,4 +110,4 @@
"vite-plugin-html": "3.2.2",
"vite-plugin-pwa": "1.1.0"
}
}
}

View File

@@ -48,12 +48,11 @@ const ReactCompilerConfig = {
/* ... */
}
const BUILD_FOR_SERVER_SERVE = process.env.BUILD_FOR_SERVER_SERVE === '1'
// https://vitejs.dev/config/
export default defineConfig(({ command }) => {
const isBuild = command === 'build'
export default defineConfig(() => {
return {
base: isBuild ? '/static/web/' : '/',
base: BUILD_FOR_SERVER_SERVE ? '/static/web/' : '/',
plugins: [
codeInspectorPlugin({
bundler: 'vite',

View File

@@ -7,7 +7,7 @@
"main": "index.ts",
"scripts": {
"build": "vite build",
"build:web": "AFILMORY_EMBED_MANIFEST=false pnpm --filter @afilmory/web build",
"build:web": "AFILMORY_EMBED_MANIFEST=false BUILD_FOR_SERVER_SERVE=1 pnpm --filter @afilmory/web build",
"db:generate": "pnpm -C ../../packages/db db:generate",
"db:migrate": "pnpm -C ../../packages/db db:migrate",
"db:studio": "pnpm -C ../../packages/db db:studio",