Skip to content

Instantly share code, notes, and snippets.

@marceldegraaf
Created September 14, 2012 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marceldegraaf/3723300 to your computer and use it in GitHub Desktop.
Save marceldegraaf/3723300 to your computer and use it in GitHub Desktop.
Only run assets:precompile when assets have been changed
namespace :deploy do
namespace :assets do
task :precompile, :roles => :web, :except => { :no_release => true } do
precompile_command = %Q{cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile}
if remote_file_exists?("#{current_path}/REVISION")
from = source.next_revision(current_revision)
if capture("cd #{latest_release} && #{source.local.log(from)} vendor/assets/ app/assets/ | wc -l").to_i > 0
run precompile_command
else
logger.info "Skipping asset pre-compilation because there were no asset changes"
end
else
run precompile_command
end
end
end
end
@chrisdebruin
Copy link

Nice! thnx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment