Skip to content

Instantly share code, notes, and snippets.

@joonty
Created February 5, 2014 11:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joonty/8821526 to your computer and use it in GitHub Desktop.
Save joonty/8821526 to your computer and use it in GitHub Desktop.
Capistrano local asset compilation
namespace :assets do
desc 'Run the precompile task locally and rsync with shared'
task :precompile, :roles => :web, :except => { :no_release => true } do
unless ENV['SKIP_ASSETS']
if ENV['FORCE_ASSETS'] || releases.length <= 1 || capture("cd #{latest_release} && #{source.local.log(source.next_revision(current_revision))} vendor/assets/ app/assets/ | wc -l").to_i > 0
system('bundle exec rake assets:precompile')
puts "syncing assets with shared directory..."
%x{rsync --recursive --times --rsh=ssh --compress --human-readable --progress public/assets #{user}@#{host}:#{shared_path}}
system('bundle exec rake assets:clean')
else
logger.info "Skipping asset pre-compilation because there were no asset changes"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment