Skip to content

Instantly share code, notes, and snippets.

@dfang
Forked from basti/application.rb
Created June 4, 2014 05:31
Show Gist options
  • Save dfang/04a0e132413f5784aac8 to your computer and use it in GitHub Desktop.
Save dfang/04a0e132413f5784aac8 to your computer and use it in GitHub Desktop.
# Speed things up by not loading Rails env
config.assets.initialize_on_precompile = false
# Updated to work with Capistrano 3 and Rails 4; compiles assets in given stage in order
# to use settings for that stage ... rm assets when we're done
namespace :deploy do
after :updated, "assets:precompile"
end
namespace :assets do
desc "Precompile assets locally and then rsync to web servers"
task :precompile do
on roles(:web) do
rsync_host = host.to_s # this needs to be done outside run_locally in order for host to exist
run_locally do
with rails_env: fetch(:stage) do
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
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment