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.
Add local-precompile to your Gemfile:
group :development do
gem 'local_precompile', '~> 0.3.3', require: false
endRemove 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: falseproduction:
compile: falseRemove 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
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.
Pull requests welcome: fork, make a topic branch, commit (squash when possible) with tests and I'll happily consider.
Copyright (c) 2021 Denis Arushanov