title: Make Cordova wait for async hook to finish
body: <p>In my Cordova project, I have a hook which does RequireJS optimization (r.js) on <code>after_prepare</code>. That optimization is inherently asynchronous, so my hook code returns before all optimization is fully finished.</p>
  
  <p>For example, this causes issues when running <code>cordova run browser</code>: On the first page load, optimization has not finished yet and the site looks broken.</p>
  
  <p>Is there a way to make the Cordovoa build process to block until a certain hook fires a callback? Or can the optimizer be run in a blocking/sync way?</p>
  
  <p>An alternative I could think of is using a different process for optimization and busy-wait in the main for it to finish, but that looks like an overkill and bad practice to me.</p>