Speed up the app, run production build, remove chunk ink, start App.jsx split

Performance:
- Lazy-load pages, docx, and mammoth (initial JS 1,298 KB -> ~290 KB)
- Gzip responses and cache hashed assets for a year
- Memoize DrawCanvas strokes so ink isn't redrawn on every render
- Precompute whole-Bible search index and defer the query while typing
- Reload once if a lazy chunk is missing after a deploy

Deployment:
- setup.sh builds and runs one production server on APP_PORT (default
  5173); --dev keeps the old Vite dev setup
- Session cookie uses secure: 'auto' so login works behind any proxy

Chunk editor:
- Remove the Draw layout, Ink Notes panel, and ink in HTML export
  (existing inkStrokes data is left in saved projects)

Refactor:
- Move module-level helpers out of App.jsx into src/utils/*
- Extract Bible reader state and logic into hooks/useBibleReader

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
nmemmertandClaude Opus 5.5 committed 2026-09-22 14:34:13 -04:00
1 parent 00932dee4a
commit ade7f1af6f
20 files changed
+1314 -1252

No files matched your search

+45 -9
View File
@@ -1,6 +1,20 @@
#!/usr/bin/env bash
# Installs dependencies, builds the frontend, and runs the app.
#
# bash setup.sh Production: one Express server serves the optimized
# build + API on $APP_PORT (default 5173).
# bash setup.sh --dev Development: Express API on 3001 + Vite dev server
# with hot reload (slower; not for real users).
set -euo pipefail
MODE="prod"
if [ "${1:-}" = "--dev" ]; then
MODE="dev"
fi
# Production serves on the port the Vite dev server used to use, so an
# existing reverse proxy pointed at it keeps working. Override with APP_PORT=.
APP_PORT="${APP_PORT:-5173}"
PREFERRED_VITE_PORT=5173
MAX_VITE_PORT=5200
API_PORT=3001
@@ -41,7 +55,7 @@ stop_pid_file() {
fi
}
echo "=== Bible Study App Setup ==="
echo "=== Bible Study App Setup ($MODE) ==="
echo ""
# ── Node check ───────────────────────────────────────────────────────────────
@@ -68,7 +82,35 @@ echo ""
echo "Installing dependencies..."
npm install
# ── Find a free Vite port ─────────────────────────────────────────────────────
# ── Production ────────────────────────────────────────────────────────────────
if [ "$MODE" = "prod" ]; then
# Build before stopping anything, so a failed build leaves the running site up.
echo ""
echo "Building frontend..."
npm run build
stop_pid_file "$API_PID_FILE" "server"
stop_pid_file "$VITE_PID_FILE" "Vite dev server"
echo ""
echo "Starting production server on http://localhost:$APP_PORT"
echo "Logs: $API_LOG_FILE"
NODE_ENV=production PORT="$APP_PORT" \
nohup node "$ROOT_DIR/server/index.js" > "$API_LOG_FILE" 2>&1 &
echo $! > "$API_PID_FILE"
echo "Server PID: $(cat "$API_PID_FILE")"
echo ""
echo "To stop: kill \$(cat .api.pid)"
echo "To view logs: tail -f .api.log"
exit 0
fi
# ── Development ───────────────────────────────────────────────────────────────
stop_pid_file "$API_PID_FILE" "API server"
stop_pid_file "$VITE_PID_FILE" "Vite server"
echo ""
VITE_PORT=$(find_port)
if [ -z "$VITE_PORT" ]; then
@@ -82,11 +124,6 @@ else
echo "Port $VITE_PORT is available for Vite."
fi
# ── Stop any previously running instances ─────────────────────────────────────
stop_pid_file "$API_PID_FILE" "API server"
stop_pid_file "$VITE_PID_FILE" "Vite server"
# ── Start Express API server ──────────────────────────────────────────────────
echo ""
echo "Starting API server on http://localhost:$API_PORT"
echo "API logs: $API_LOG_FILE"
@@ -98,7 +135,6 @@ echo "API server PID: $(cat "$API_PID_FILE")"
# Give the API a moment to initialise before Vite starts
sleep 1
# ── Start Vite dev server ─────────────────────────────────────────────────────
echo ""
echo "Starting Vite dev server on http://localhost:$VITE_PORT"
echo "Vite logs: $VITE_LOG_FILE"
@@ -112,4 +148,4 @@ echo "Both servers are running."
echo ""
echo "To stop both: kill \$(cat .api.pid) \$(cat .vite.pid)"
echo "To view API logs: tail -f .api.log"
echo "To view Vite logs: tail -f .vite.log"
echo "To view Vite logs: tail -f .vite.log"