#!/usr/bin/env bash set -Eeuo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # shellcheck source=common.sh source "$SCRIPT_DIR/common.sh" cd "$PROJECT_ROOT" INSTALL=0 WATCH=0 usage() { cat <<'TXT' Build the embedded Web UI CSS with the local Tailwind CLI. Usage: ./scripts/build-web.sh ./scripts/build-web.sh --install install npm dev dependencies first ./scripts/build-web.sh --watch rebuild CSS while editing web files The controller never loads Tailwind or any CSS from a CDN. web/styles.css is committed and embedded into the Rust binary, so Node.js is not required at runtime. TXT } while [[ $# -gt 0 ]]; do case "$1" in --install) INSTALL=1; shift ;; --watch) WATCH=1; shift ;; -h|--help) usage; exit 0 ;; *) echo "Unknown argument: $1" >&2; usage; exit 2 ;; esac done if [[ "$INSTALL" -eq 1 ]]; then command -v npm >/dev/null 2>&1 || fail "npm is required for --install. Install Node.js/npm first." say "Installing local Tailwind build dependency" npm install --no-audit --no-fund fi TAILWIND="$PROJECT_ROOT/node_modules/.bin/tailwindcss" if [[ ! -x "$TAILWIND" ]]; then fail "Local Tailwind CLI is missing. Run: ./scripts/build-web.sh --install" fi if [[ "$WATCH" -eq 1 ]]; then say "Watching the Web UI with local Tailwind" exec "$TAILWIND" -c ./tailwind.config.js -i ./web/tailwind.input.css -o ./web/styles.css --watch fi say "Building the Web UI with local Tailwind" "$TAILWIND" -c ./tailwind.config.js -i ./web/tailwind.input.css -o ./web/styles.css --minify say "Generated web/styles.css"