From 35583115ff8796f70f192c0990bf978b4f064ab4 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 31 May 2026 13:24:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Vite=20outputs=20directly=20to=20web/app?= =?UTF-8?q?/=20=E2=80=94=20no=20dist=20copy=20needed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - vite.config.mts: outDir changed from web/app/dist to web/app - .gitignore: ignore web/app/index.html + web/app/assets/ (build artifacts) - deploy/deploy-frontend.sh: automated build+deploy+verify script Deployment is now: bash deploy/deploy-frontend.sh Co-Authored-By: Claude Opus 4.8 (1M context) --- .gitignore | 4 +++ deploy/deploy-frontend.sh | 51 +++++++++++++++++++++++++++++++++++++++ frontend/vite.config.mts | 9 ++++--- 3 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 deploy/deploy-frontend.sh diff --git a/.gitignore b/.gitignore index b4b7473b..060fae22 100644 --- a/.gitignore +++ b/.gitignore @@ -54,6 +54,10 @@ node_modules/ web/css/tailwind-output.css # Build output (Vite/Vuetify frontend) +# Vite outputs directly to web/app/ — ignore generated assets +web/app/index.html +web/app/assets/ +# Legacy dist dir (no longer used) **/dist/ # Uploads diff --git a/deploy/deploy-frontend.sh b/deploy/deploy-frontend.sh new file mode 100644 index 00000000..bac73f3c --- /dev/null +++ b/deploy/deploy-frontend.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# deploy-frontend.sh — Build Vuetify frontend and deploy to server +# +# Usage: bash deploy/deploy-frontend.sh +# Run from the Nexus project root directory. + +set -euo pipefail + +echo "═══ Nexus Frontend Deploy ═══" + +# 1. Build +echo "▶ Building frontend..." +cd frontend && npx vite build && cd .. +echo "✓ Build complete" + +# 2. Tar the build output (index.html + assets/) +echo "▶ Packaging..." +tar czf /tmp/nexus-frontend.tar.gz -C web/app index.html assets/ +echo "✓ Package ready ($(du -h /tmp/nexus-frontend.tar.gz | cut -f1))" + +# 3. Upload to server +echo "▶ Uploading to server..." +scp /tmp/nexus-frontend.tar.gz nexus:/tmp/nexus-frontend.tar.gz +echo "✓ Upload complete" + +# 4. Extract on server (overwrites old index.html + assets) +echo "▶ Deploying on server..." +ssh nexus "cd /www/wwwroot/api.synaglobal.vip/web/app && tar xzf /tmp/nexus-frontend.tar.gz && rm /tmp/nexus-frontend.tar.gz" +echo "✓ Extracted" + +# 5. Restart backend +echo "▶ Restarting backend..." +ssh nexus "supervisorctl restart nexus" +echo "✓ Restarted" + +# 6. Health check +sleep 3 +HEALTH=$(ssh nexus "curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:8600/health" 2>/dev/null || echo "000") +SPA=$(ssh nexus "curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:8600/app/" 2>/dev/null || echo "000") + +echo "" +echo "═══ Verification ═══" +echo " /health → $HEALTH" +echo " /app/ → $SPA" + +if [ "$HEALTH" = "200" ] && [ "$SPA" = "200" ]; then + echo "✓ Deploy successful!" +else + echo "✗ Verification failed — check server logs" + exit 1 +fi diff --git a/frontend/vite.config.mts b/frontend/vite.config.mts index 358fe999..b13446be 100644 --- a/frontend/vite.config.mts +++ b/frontend/vite.config.mts @@ -43,12 +43,13 @@ export default defineConfig({ '.vue', ], }, - // Production build: output to web/app/dist/ so the backend can serve it - // alongside the existing HTML pages. Base path matches the backend's /app/ route. + // Production build: output directly to web/app/ so the backend's StaticFiles + // mount at /app/ serves the SPA without a copy step. + // Old HTML pages (login.html etc.) coexist but are no longer the primary entry. base: '/app/', build: { - outDir: fileURLToPath(new URL('../web/app/dist', import.meta.url)), - emptyOutDir: true, + outDir: fileURLToPath(new URL('../web/app', import.meta.url)), + emptyOutDir: false, // Don't delete old HTML pages still in git }, server: { port: 3000,