CodeKit + HTML gzip
[UPDATE] CodeKit 3 is now available and hooks work a bit differently now. This “should” still work, but, I’ll try to have an update on this using the new hooks.
This is a quick write-up on how to gzip your HTML files with CodeKit Version 2.3+ hooks; Jade is used in the example but any of the HTML processors available should work the same.
First you’ll need to setup a hook, the hook I’ve used is:
Anyof the following are true
The filename of any processed file
Now you’ll need to select
Shell Script (/bin/sh) from the drop down and paste the follow into the textarea:
The above code accesses a newly available environment variable that CodeKit is now setting
CK_OUTPUT_PATHS. This variable is a
: delimited string of all the files that were produced by the action defined in the hook above.
gzip -nc $i > $i.gz takes the current HTML file, gzips it, and saves a new version of it with the
.gz extension. If you just want to replace the current HTML file with no
.gz extension all you should have to do is use
gzip -nc $i instead which will convert the current html files into a gzipped version.
With this hook setup, if you save a jade file that only effects one file then only one file will be gzipped and if you change a layout that’s extended by many other files then all of those files will be gzipped.