Files
streamline/control-web/scm_build.sh
T
2026-11-16 17:26:44 -08:00

39 lines
1.4 KiB
Bash

#!/bin/bash
# SCM build for the control-web frontend (Vite SPA in a Bun monorepo).
# Wire SCM's build command to: bash control-web/scm_build.sh
# Produces repo-root ./output = the built static site (index.html + assets/).
# NOTE: VITE_* are inlined at build time — set them (VITE_SSO_SERVICE_ID, and
# leave VITE_DEBUG unset for a prod build) in the SCM build env, not the repo.
# Source the login profile (SCM build shell PATH) BEFORE strict mode — /etc/profile
# references unset vars that would trip `set -u`.
. /etc/profile 2>/dev/null || true
set -euo pipefail
# Ensure bun is on PATH. SCM/CI build machines often don't have it pre-installed,
# and a non-login shell won't have sourced ~/.bashrc, so add the usual install dirs.
export PATH="$HOME/.bun/bin:/usr/local/bin:/opt/homebrew/bin:$PATH"
if ! command -v bun >/dev/null 2>&1; then
echo "bun not found, installing..."
curl -fsSL https://bun.sh/install | bash
export PATH="$HOME/.bun/bin:$PATH"
fi
bun --version
# Vite SPA emits a single static bundle → only ./output (no output_resource);
# clean both so a stale one from another build never lingers.
rm -rf output output_resource
# Install workspace deps (control-web depends on @bbbug/shared via workspace:*),
# so install from the repo root rather than inside control-web.
bun install --frozen-lockfile
cd control-web
rm -rf dist
bun run build
cp -r dist ../output