From d4b48491cfaafaee5e7c9c88227055fd884d60f4 Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 19 Apr 2025 14:02:54 +0200 Subject: Add build command --- README.md | 4 ++++ bin/build | 8 ++++++++ frontend/bin/compile-sass | 13 ++++++++++++- frontend/bin/compile-ts | 14 +++++++++++++- frontend/bin/dev-server | 2 ++ 5 files changed, 39 insertions(+), 2 deletions(-) create mode 100755 bin/build diff --git a/README.md b/README.md index df7eab6..afe7c5f 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,10 @@ Credentials are: - john@mail.com / password - lisa@mail.com / password +## Build + + nix develop --command bin/build + ## Improvements - mobile view diff --git a/bin/build b/bin/build new file mode 100755 index 0000000..907415a --- /dev/null +++ b/bin/build @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -euo pipefail + +# frontend +(cd frontend; make clean build) + +# backend +(cd backend; zig build --release=fast) diff --git a/frontend/bin/compile-sass b/frontend/bin/compile-sass index 79d5415..fc99767 100755 --- a/frontend/bin/compile-sass +++ b/frontend/bin/compile-sass @@ -1,3 +1,14 @@ #!/usr/bin/env bash set -euo pipefail -sass --no-error-css styles/main.sass ../backend/public/main.css + +if [ -n "${IS_DEV_SERVER:-}" ]; then + + # dev + sass --no-error-css styles/main.sass ../backend/public/main.css + +else + + # prod + sass --no-error-css --style=compressed styles/main.sass ../backend/public/main.css + +fi diff --git a/frontend/bin/compile-ts b/frontend/bin/compile-ts index 0e1d62a..019efd3 100755 --- a/frontend/bin/compile-ts +++ b/frontend/bin/compile-ts @@ -2,5 +2,17 @@ set -euo pipefail cd ts + tsc --noEmit -esbuild --bundle src/main.ts > ../../backend/public/main.js + +if [ -n "${IS_DEV_SERVER:-}" ]; then + + # dev + esbuild --bundle src/main.ts > ../../backend/public/main.js + +else + + # prod + esbuild --minify --bundle src/main.ts > ../../backend/public/main.js + +fi diff --git a/frontend/bin/dev-server b/frontend/bin/dev-server index 4819033..3601105 100755 --- a/frontend/bin/dev-server +++ b/frontend/bin/dev-server @@ -1,6 +1,8 @@ #!/usr/bin/env bash set -euo pipefail +export IS_DEV_SERVER=1 + # Killing watchexec ourselves, it may not be done otherwise. function finish { if [ -n "${LIVE_SERVER_PID:-}" ]; then -- cgit v1.2.3