Last active
February 24, 2018 09:35
-
-
Save varnav/261868d0bb2e07bf195b1a310c41ee68 to your computer and use it in GitHub Desktop.
Compress website assets for serving by gzip static nginx plugin.
This file contains hidden or 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
| #!/usr/bin/env zsh | |
| # https://gist.github.com/Eriner/6be8c43d8aff8134f7d8fb547612aadf | |
| filetypes=(html xml css) | |
| zcomp() { | |
| print "zopfli compressing ${1}" | |
| for file in ./_site/**/*.${1}; do | |
| zopfli --i1000 ${file} | |
| done | |
| } | |
| bcomp() { | |
| print "brotli compressing ${1}" | |
| for file in ./_site/**/*.${1}; do | |
| bro --force --quality 11 --input ${file} --output ${file}.br | |
| chmod 644 ${file}.br | |
| done | |
| } | |
| for type in ${filetypes}; do | |
| zcomp ${type} | |
| bcomp ${type} | |
| done | |
| print "done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment