Last active
October 13, 2015 19:18
-
-
Save allejo/4243333 to your computer and use it in GitHub Desktop.
Minify CSS and JS files in a project
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 | |
for css_file in css/* | |
do | |
if [[ "$css_file" == *".min."* ]] | |
then | |
continue | |
fi | |
if [[ "$css_file" -nt "${css_file%.*}.min.css" ]] | |
then | |
rm css/${css_file%.*}.min.css | |
java -jar /Applications/YUICompressor/yuicompressor.jar $css_file -o ${css_file%.*}.min.css | |
fi | |
done | |
for js_file in js/* | |
do | |
if [[ "$js_file" == *".min."* ]] || [[ ! "$js_file" == *".yourname."* ]] | |
then | |
continue; | |
fi | |
if [[ "$js_file" -nt "${js_file%.*}.min.js" ]] | |
then | |
java -jar /Applications/YUICompressor/yuicompressor.jar $js_file -o ${js_file%.*}.min.js | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment