Skip to content

Instantly share code, notes, and snippets.

@anandnalya
Created August 4, 2011 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anandnalya/1124427 to your computer and use it in GitHub Desktop.
Save anandnalya/1124427 to your computer and use it in GitHub Desktop.
Minifying Javascript/css without changing file references in your source
#enable rewriting
RewriteEngine on
RewriteRule /(.*)\.js /$1-min.js
RewriteRule /(.*)\.css /$1-min.css
#!/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