From 5b19830a2deaeced88996bcdb29b4cd37debd070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Thu, 27 Nov 2025 07:54:57 +0000 Subject: [PATCH] do not rebuild static files all the time --- scripts/Makefile.static | 28 ++++++++++++++++++++++------ scripts/build | 2 +- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/scripts/Makefile.static b/scripts/Makefile.static index 5f21944..99fbac3 100644 --- a/scripts/Makefile.static +++ b/scripts/Makefile.static @@ -7,11 +7,27 @@ GZ = $(patsubst %,%.gz,$(SRCS)) .PHONY: all all: $(ZSTD) $(BR) $(GZ) -%.br: % - brotli $< +define MAKETARGET -%.zst: % - zstd -19 $< +$(1).br: $(1).xxhash + brotli -f $(1) + touch $(1).br -%.gz: % - zopfli $< +$(1).zst: $(1).xxhash + zstd -f -19 $(1) + touch $(1).zst + +$(1).gz: $(1).xxhash + zopfli $(1) + touch $(1).gz + +# https://github.com/gohugoio/hugo/issues/10842 +$(1).xxhash: $(1) + current=$$$$(xxhsum $$< | cut -d' ' -f1); \ + if [ ! -f $$< ] || [ "$$$$(cat $$@ 2>/dev/null)" != "$$$$current" ]; then \ + echo "$$$$current" > $$@; \ + fi + +endef + +$(foreach f,$(SRCS),$(eval $(call MAKETARGET,$(f)))) diff --git a/scripts/build b/scripts/build index b554ec6..7a79feb 100755 --- a/scripts/build +++ b/scripts/build @@ -2,6 +2,6 @@ set -xeuo pipefail cd "$(git rev-parse --show-toplevel)" -hugo --cleanDestinationDir --printPathWarnings --panicOnWarning +hugo --printPathWarnings --panicOnWarning find public -type d | xargs -P4 -n1 make -j4 -sf $PWD/scripts/Makefile.static -C