Created
August 4, 2011 03:18
-
-
Save anandnalya/1124427 to your computer and use it in GitHub Desktop.
Minifying Javascript/css without changing file references in your source
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
#enable rewriting | |
RewriteEngine on | |
RewriteRule /(.*)\.js /$1-min.js | |
RewriteRule /(.*)\.css /$1-min.css |
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
#!/bin/bash | |
#Execute this script after checking out the latest source from repository. | |
#Minify all javascript files | |
cd /path/to/javascript | |
for x in `ls *.js` | |
do | |
java -jar /path/to/compressor/yuicompressor-2.4.2.jar -o ${x%%.*}-min.js --preserve-semi $x | |
done | |
#Minfiy all css files | |
cd /path/to/css | |
for x in `ls *.css` | |
do | |
java -jar /path/to/compressor/yuicompressor-2.4.2.jar -o ${x%%.*}-min.css $x | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment