fix: Vite outputs directly to web/app/ — no dist copy needed

- 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) <noreply@anthropic.com>
This commit is contained in:
Your Name
2026-05-31 13:24:22 +08:00
parent f745714530
commit 35583115ff
3 changed files with 60 additions and 4 deletions
+4
View File
@@ -54,6 +54,10 @@ node_modules/
web/css/tailwind-output.css web/css/tailwind-output.css
# Build output (Vite/Vuetify frontend) # 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/ **/dist/
# Uploads # Uploads
+51
View File
@@ -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
+5 -4
View File
@@ -43,12 +43,13 @@ export default defineConfig({
'.vue', '.vue',
], ],
}, },
// Production build: output to web/app/dist/ so the backend can serve it // Production build: output directly to web/app/ so the backend's StaticFiles
// alongside the existing HTML pages. Base path matches the backend's /app/ route. // 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/', base: '/app/',
build: { build: {
outDir: fileURLToPath(new URL('../web/app/dist', import.meta.url)), outDir: fileURLToPath(new URL('../web/app', import.meta.url)),
emptyOutDir: true, emptyOutDir: false, // Don't delete old HTML pages still in git
}, },
server: { server: {
port: 3000, port: 3000,