For (automatic) deployments our tool of choice is Webistrano, which is based on Capistrano, which is written in Ruby.
Capistrano has this concept of recipes, which are small scripts that you write to do specific tasks during deployment.
But for the minification and deployment of that, i was bound to some constraints:
- We’re using the yuicompressor (java)
- Deploy target machines do not have java installed
- So we have to do the minification locally
After doing some initial research it was quite easy to do, and i came up with the following code:
Of course, you can rewrite this script to work with any other local command too.
Note/disclaimer: This script uses the copy_cache directive. I’m not a capistrano expert, but this variable might not be available to all deployment strategies. This script might not work for you if copied 1:1. But i suppose you get the idea.