A long-lived project that still receives updates
Contains cap tasks
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 2.0, >= 2.0.2
~> 13.0, >= 13.0.1
 Project Readme

Capistrano Local Precompile

The slowest part in a rails application is in the assets compiling. So let's throw it out! This gem adds a local build of assets and packs right on your machine and then uploads all the files to the server.

Usage

Add local-precompile to your Gemfile:

group :development do
  gem 'local_precompile', '~> 0.3.3', require: false
end

Remove any gems associated with assets, like:

gem 'capistrano-faster-assets'
gem 'quiet_assets'

Then add the following line to your Capfile:

require 'local_precompile/capistrano'

Remove the following line from your Capfile:

require 'capistrano/rails/assets'

Change webpacker compile options in config/webpacker.yml to false:

staging:
  compile: false
production:
  compile: false

Remove node modules folder from set :linked_dirs your config/deploy.rb.

Here's the full set of configurable options:

set :precompile_env             # default: fetch(:rails_env) || 'production'
set :assets_dir                 # default: "public/assets"
set :packs_dir                  # default: "public/packs"
set :rsync_cmd                  # default: "rsync -av --delete"

Capistrano supports dry run mode. In that case the rsync command will not actually be run but only shown in stdout:

cap production deploy --dry-run

Acknowledgement

This gem is based on another gem with the same functionality but improved capistrano-local-precompile.

In turn that gem is derived from gists by uhlenbrock and keighl.

So many thanks to this guys.

Contributing

Pull requests welcome: fork, make a topic branch, commit (squash when possible) with tests and I'll happily consider.

Copyright

Copyright (c) 2021 Denis Arushanov