do not rebuild static files all the time

This commit is contained in:
2025-11-27 07:54:57 +00:00
parent 80e1bc667d
commit 5b19830a2d
2 changed files with 23 additions and 7 deletions

View File

@@ -7,11 +7,27 @@ GZ = $(patsubst %,%.gz,$(SRCS))
.PHONY: all .PHONY: all
all: $(ZSTD) $(BR) $(GZ) all: $(ZSTD) $(BR) $(GZ)
%.br: % define MAKETARGET
brotli $<
%.zst: % $(1).br: $(1).xxhash
zstd -19 $< brotli -f $(1)
touch $(1).br
%.gz: % $(1).zst: $(1).xxhash
zopfli $< 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))))

View File

@@ -2,6 +2,6 @@
set -xeuo pipefail set -xeuo pipefail
cd "$(git rev-parse --show-toplevel)" 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 find public -type d | xargs -P4 -n1 make -j4 -sf $PWD/scripts/Makefile.static -C