j7qqsa
Last Updated: February 25, 2016
·
1.058K
· liquidise
0fd1ac94827ef5f38c0a9b2eec9f14e6

Minify Your CSS inside of Textmate

read more at: Ben Roux's Blog

In your Bundles menu, go to Edit Bundles and select your favorite CSS Bundle (I am personally a huge proponent of mCss). Add a new Command, and enter make the command contents the following code:

# Create the minified filename
NEWFILE=${TM_FILENAME%\.css}'.min.css'

# Minify into that file
curl -X POST -s --data-urlencode "input@${TM_FILENAME}" \
    http://www.cssminifier.com/raw > $NEWFILE

# And open it
mate $NEWFILE

You can make your key equivalent anything you'd like, I set mine to Cmd + Shift + R. Once you have done this, give it a whirl. You should see that your styles.css generates a styles.min.css in the same directory, as well as opens it in Textmate.

To note: if you don't have the Textmate command line utility installed, simply delete the last line of this command to stop seeing errors.

Say Thanks
Respond