Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Roots Bedrock: Copy production assets for Roots theme
# The Roots theme by default does not check production assets into Git, so
# they are not deployed by Capistrano when using the Bedrock stack. The
# following will compile and deploy those assets. Copy this to the bottom of
# your config/deploy.rb file.
# Based on information from this thread:
# and specifically this gist from christhesoul:
# First we need to set some variables so we know where things are. You should
# only have to modify :theme_path here, :local_app_path and :local_theme_path
# are set from that.
set :theme_path,'web/app/themes/roots')
set :local_app_path,'../')
set :local_theme_path, fetch(:local_app_path).join(fetch(:theme_path))
# Next we list the production assets we want to deploy. We could change things
# around so that all our production assets are generated into a single
# directory and upload that, but it would involve touching a lot of things.
# Listing them each explicitly keeps our changes to just the deployment
# configuration.
set :production_assets, [
'assets/vendor/bootstrap/fonts/glyphicons-halflings-regular.svg'].map {|path| }
namespace :deploy do
# The :compile_assets task will run 'grunt build' in our theme directory
# to build the production assets.
task :compile_assets do
run_locally do
within fetch(:local_theme_path) do
execute :grunt, :build
# The :copy_assets task first runs :compile_assets, then goes through the
# list of production assets and uploads them to the server. It also creates
# the target directories if necessary.
task :copy_assets do
invoke 'deploy:compile_assets'
on roles(:web) do
fetch(:production_assets).each do |path|
execute :mkdir, "-p", release_path.join(fetch(:theme_path)).join(path.dirname())
upload! fetch(:local_theme_path).join(path).to_s, release_path.join(fetch(:theme_path)).join(path)
# This tells Capistrano to copy our production assets to the server after it
# has created the release directory but before it has published the release.
before "deploy:updated", "deploy:copy_assets"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment