You would normally have a build process which turns the source into a deployable form. This would include any compilation, unit tests, compression etc.
YUI compressor has a build tool for just that http://yuilibrary.com/download/builder/
Also check out ANT http://ant.apache.org/