Created
January 18, 2013 15:54
-
-
Save lxcid/4565541 to your computer and use it in GitHub Desktop.
Replaces deploy:assets:precompile task to do assets precompilation locally.
This file contains hidden or 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
# Base on http://stackoverflow.com/a/12839484/379604 and https://github.com/capistrano/capistrano/blob/master/lib/capistrano/recipes/deploy/assets.rb | |
namespace :deploy do | |
namespace :assets do | |
desc <<-DESC | |
Run the asset precompilation rake task locally. You can specify the \ | |
full path to the rake executable by setting the rake variable. You \ | |
can also specify additional environment variables to pass to rake via \ | |
the asset_env variable. The defaults are: | |
set :rake, "rake" | |
set :rails_env, "production" | |
set :asset_env, "RAILS_GROUPS=assets" | |
DESC | |
task :precompile, :roles => assets_role, :except => { :no_release => true } do | |
run_locally "#{rake} RAILS_ENV=#{rails_env.to_s.shellescape} #{asset_env} assets:precompile" | |
run_locally "cd -- public && tar -zcvf #{assets_prefix}.tar.gz #{assets_prefix}" | |
top.upload "public/#{assets_prefix}.tar.gz", "#{shared_path.shellescape}", :via => :scp | |
run "cd -- #{shared_path.shellescape} && tar -zxvf #{assets_prefix}.tar.gz && rm -- #{assets_prefix}.tar.gz" | |
run_locally "rm -- public/#{assets_prefix}.tar.gz && rm -rf -- public/#{assets_prefix}" | |
run "cp -- #{shared_path.shellescape}/assets/manifest.yml #{current_release.shellescape}/assets_manifest.yml" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment