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
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))))