Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a deploy script that git pulls code from a repo. I'd like to minify the javascript (js) and css files in that deploy script using yuicompressor.

In order to minify one js file you'd use something like this:

java -jar yuicompressor-2.4.2.jar test.js -o test.js

How can I do that to all js and css files recursively (inside subdirectories and across all files while excluding files that aren't js or css)?

Thanks!!

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

You can use find + exec

$ find . \( -iname *.js -o -iname *.css \) -exec java -jar /full/path/to/yuicompressor-2.4.2.jar {} -o {} \;

Run it on the root directory of where are your .css and .js are.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.