Skip to content

Instantly share code, notes, and snippets.

@allejo
Last active October 13, 2015 19:18
Show Gist options
  • Save allejo/4243333 to your computer and use it in GitHub Desktop.
Save allejo/4243333 to your computer and use it in GitHub Desktop.
Minify CSS and JS files in a project
#!/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