Skip to content

Instantly share code, notes, and snippets.

@Calinou
Created April 30, 2018 17:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Calinou/2c90853c3b0573f710ad78420541cdeb to your computer and use it in GitHub Desktop.
Save Calinou/2c90853c3b0573f710ad78420541cdeb to your computer and use it in GitHub Desktop.
Compress static assets to Brotli (usable by nginx's brotli_static module)
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
DIR=${1:-}
if [[ "$DIR" == "" ]]; then
echo "Usage: $(basename $0) <path>"
exit 1
fi
for file in $(find "$DIR" -type f -iname '*.css' -or -iname '*.js' -or -iname '*.json' -or -iname '*.svg' -or -iname '*.xml'); do
echo -n "Compressing ${file}... "
brotli --input $file --force --output ${file}.br
echo "done."
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment