webui: optimize npm ci caching for faster builds
Add caching for npm ci in webui build process by tracking
package-lock.json changes separately from other source files.
Co-Authored-By: sketch <hello@sketch.dev>
Change-ID: sce58f3444bbcc029k
diff --git a/build/webui.sh b/build/webui.sh
index ec7c62a..ee9659d 100755
--- a/build/webui.sh
+++ b/build/webui.sh
@@ -1,6 +1,8 @@
#!/bin/bash
set -e
+echo "[$(date '+%H:%M:%S')] Starting webui build..."
+
# Use a content-based hash of the webui dir to avoid unnecessary rebuilds.
OUTPUT_DIR="embedded/webui-dist"
# go:embed ignores files that start with a '.'
@@ -22,11 +24,14 @@
if [ -f "$HASH_FILE" ] && [ -d "$OUTPUT_DIR" ]; then
STORED_HASH=$(cat "$HASH_FILE")
if [ "$CURRENT_HASH" = "$STORED_HASH" ]; then
- # No changes, skip rebuild
+ echo "No changes, skipping rebuild"
exit 0
fi
fi
+echo "[$(date '+%H:%M:%S')] Removing old output directory..."
rm -rf "$OUTPUT_DIR"
+echo "[$(date '+%H:%M:%S')] Running genwebui..."
unset GOOS GOARCH && go run ./cmd/genwebui -- "$OUTPUT_DIR"
echo "$CURRENT_HASH" >"$HASH_FILE"
+echo "[$(date '+%H:%M:%S')] Webui build completed"