Files
functional-programming-snake/scala/build-web.sh
T

14 lines
640 B
Bash
Executable File

#!/usr/bin/env bash
# Usage: ./build-web.sh
# Compiles src/ + web/ to JavaScript with Scala.js: web/dist/snake.js (index.html) and web/dist/pong.js (pong.html).
# Then serve the repo root (node scripts/serve.mjs) and open http://localhost:8000/scala/index.html.
set -euo pipefail
cd "$(dirname "$0")"
SCALA_CLI="${SCALA_CLI:-$(command -v scala-cli || echo "$HOME/.local/bin/scala-cli")}"
mkdir -p web/dist
build() { # <main class> <output file>
"$SCALA_CLI" --power package --js --js-module-kind es src web project.scala --main-class "$1" -o "$2" -f
}
build snake.web.SnakeMain web/dist/snake.js
build snake.web.PongMain web/dist/pong.js