-
-
Save crmaxx/1646f62d36493212b99b748cc6780d78 to your computer and use it in GitHub Desktop.
capistrano 3: precompile assets on local machine then upload
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :deploy do | |
namespace :assets do | |
Rake::Task['deploy:assets:precompile'].clear_actions | |
desc "Precompile assets on local machine and upload them to the server." | |
task :precompile do | |
run_locally do | |
execute 'RAILS_ENV=production bundle exec rake assets:precompile' | |
end | |
on roles(:web) do | |
within release_path do | |
asset_full_path = "#{release_path}/public/#{fetch(:assets_prefix)}" | |
asset_parent_path = File.dirname(asset_full_path) | |
execute "mkdir -p #{asset_full_path}" | |
upload! "./public/#{fetch(:assets_prefix)}", asset_parent_path, recursive: true | |
end | |
end | |
run_locally do | |
execute "rm -r ./public/#{fetch(:assets_prefix)}" | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment