Created
April 30, 2018 17:54
-
-
Save Calinou/2c90853c3b0573f710ad78420541cdeb to your computer and use it in GitHub Desktop.
Compress static assets to Brotli (usable by nginx's brotli_static module)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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