If you deploy your static site to a Web server like Caddy, you might need to pre-compress it, especially if you want to use Brotli with Caddy as it’s only supported for pre-compressed assets.
Brotli
1
2
| find www.new -type f \( -name '*.html' -o -name '*.js' -o -name '*.css' -o -name '*.xml' -o -name '*.svg' \) \
-exec /bin/sh -c 'brotli -q 11 -o "$1.br" "$1"' /bin/sh {} \;
|
Gzip
1
2
| find www.new -type f \( -name '*.html' -o -name '*.js' -o -name '*.css' -o -name '*.xml' -o -name '*.svg' \) \
-exec /bin/sh -c 'gzip -v -f -9 -c "$1" > "$1.gz"' /bin/sh {} \;
|
Source
https://github.com/maruel/hugo-tidy/blob/main/docker-entrypoint.sh#L49