Skip to content

Instantly share code, notes, and snippets.

@Calinou
Last active September 26, 2023 12:07
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Calinou/30f21f07017d908fc74c7eccb3f469c3 to your computer and use it in GitHub Desktop.
Save Calinou/30f21f07017d908fc74c7eccb3f469c3 to your computer and use it in GitHub Desktop.
Brotli precompression script for the Godot website. Apache configuration: https://gist.github.com/Calinou/fc0fe1003c95380054f0084f9476e476
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
# Usage: Place the script in `htdocs/` and run `./static-precompress.sh themes/godotengine/assets`.
echo "Precompressing assets in \"$1\"..."
BROTLICOMMAND="$(readlink -f $(dirname "${BASH_SOURCE[0]}")/brotli)"
#BROTLICOMMAND=$(which brotli)
cd "$1"
if command -v "$BROTLICOMMAND"; then
echo "Found Brotli binary at \"$BROTLICOMMAND\"."
else
echo "ERROR: Couldn't find a Brotli binary."
exit 1
fi
find ./ -type f \
\( -iname \*.css -o -iname \*.ico -o -iname \*.js -o -iname \*.json -o -iname \*.svg \) \
-exec $BROTLICOMMAND --keep --force --quality=11 {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment