Skip to content

Instantly share code, notes, and snippets.

@reu
Created February 19, 2012 11:19
Show Gist options
  • Save reu/1863235 to your computer and use it in GitHub Desktop.
Save reu/1863235 to your computer and use it in GitHub Desktop.
Overriding capistrano assets:precompile task to precompile only when there are changes in any of the assets.
namespace :deploy do
namespace :assets do
task :precompile, :roles => :web, :except => { :no_release => true } do
if capture("cd #{latest_release} && #{source.local.log(source.next_revision(current_revision))} vendor/assets/ lib/assets/ app/assets/ | wc -l").to_i > 0
run "cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile"
else
logger.info "No changes on assets. Skipping pre-compilation."
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment