Skip to content

Instantly share code, notes, and snippets.

@fideloper
Created February 4, 2012 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save fideloper/1739262 to your computer and use it in GitHub Desktop.
Save fideloper/1739262 to your computer and use it in GitHub Desktop.
Minify with YUI shell script
# src: http://www.craig-russell.co.uk/bulk-minify-shell-script/
CSS='css'
JS='js'
FILELIST="minify.$$.tmp"
COMPORESSOR="yuicompressor-2.4.2.jar"
MINCSS="css/styles.min.css"
# Minify CSS to single file
echo -n '' > $MINCSS
ls $CSS | grep -v min > $FILELIST
while read LINE
do
OLD="$CSS/$LINE"
echo "$OLD -> $MINCSS"
java -jar yuicompressor-2.4.2.jar $OLD >> $MINCSS #bug fix: fix media queries
done < $FILELIST
# Minify JS to multiple files
ls $JS | grep -v min > $FILELIST
while read LINE
do
OLD="$JS/$LINE"
NEW=` echo "$JS/$LINE" | sed 's/.js/.min.js/g'`
echo "$OLD -> $NEW"
java -jar yuicompressor-2.4.2.jar $OLD > $NEW
done < $FILELIST
rm -f $FILELIST
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment