Skip to content

Instantly share code, notes, and snippets.

@buntine
Created July 14, 2014 01:36
Show Gist options
  • Save buntine/bf9d27ebbacba53e5c32 to your computer and use it in GitHub Desktop.
Save buntine/bf9d27ebbacba53e5c32 to your computer and use it in GitHub Desktop.
Rails 4, Capistrano 3.2.1+ local precompilation using rsync
# Clear existing task so we can replace it rather than "add" to it.
Rake::Task["deploy:compile_assets"].clear
desc "Precompile assets locally and then rsync to web servers"
task :compile_assets do
on roles(:web) do
rsync_host = host.to_s
run_locally do
with rails_env: :production do ## Set your env accordingly.
execute :bundle, "exec rake assets:precompile"
end
execute "rsync -av --delete ./public/assets/ #{fetch(:user)}@#{rsync_host}:#{shared_path}/public/assets/"
execute "rm -rf public/assets"
# execute "rm -rf tmp/cache/assets" # in case you are not seeing changes
end
end
end
@snackycracky
Copy link

thx

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