Created
February 4, 2012 18:09
-
-
Save fideloper/1739262 to your computer and use it in GitHub Desktop.
Minify with YUI shell script
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
# 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