#!/usr/bin/env bash # # Erstellt ein Production-Bundle unter dist/ (ohne Branch-Wechsel). # # Nutzung: # ./scripts/run-build.sh # ./scripts/run-build.sh --in-place # set -euo pipefail IN_PLACE=false usage() { cat <<'EOF' Usage: run-build.sh [OPTIONS] Options: --in-place Build direkt im Repository (statt dist/) -h, --help Hilfe anzeigen EOF } while [[ $# -gt 0 ]]; do case "$1" in --in-place) IN_PLACE=true shift ;; -h|--help) usage exit 0 ;; *) echo "Unbekannte Option: $1" >&2 usage >&2 exit 1 ;; esac done SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" BUILD_DIR="$ROOT/scripts/build" if ! command -v npm >/dev/null 2>&1; then echo "FEHLER: npm nicht gefunden. Bitte Node.js installieren." >&2 exit 1 fi cd "$BUILD_DIR" npm ci --no-fund --no-audit if [[ "$IN_PLACE" == true ]]; then npm run build:in-place else npm run build fi