From 20ffe0a502127b64223341769387642a84d06d42 Mon Sep 17 00:00:00 2001 From: Akshay Birajdar Date: Wed, 25 Dec 2019 00:33:27 +0530 Subject: [PATCH 1/3] Support webpacker for rails assets precompilation In Rails 6, Webpacker is the default JavaScript compiler. This commit add app/javascript/ to asset_dir as it is the default directory used by Webpacker. --- tasks/mina/rails.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasks/mina/rails.rb b/tasks/mina/rails.rb index bd07d6de..a673bc41 100644 --- a/tasks/mina/rails.rb +++ b/tasks/mina/rails.rb @@ -5,11 +5,11 @@ set :bundle_prefix, -> { %{RAILS_ENV="#{fetch(:rails_env)}" #{fetch(:bundle_bin)} exec} } set :rake, -> { "#{fetch(:bundle_prefix)} rake" } set :rails, -> { "#{fetch(:bundle_prefix)} rails" } -set :compiled_asset_path, 'public/assets' -set :asset_dirs, ['vendor/assets/', 'app/assets/'] +set :compiled_asset_path, ['public/assets', 'public/packs'] +set :asset_dirs, ['vendor/assets/', 'app/assets/', 'app/javascript/'] set :migration_dirs, ['db/migrate'] -set :shared_dirs, fetch(:shared_dirs, []).push('log', 'tmp/cache', fetch(:compiled_asset_path)) +set :shared_dirs, fetch(:shared_dirs, []).push('log', 'tmp/cache', *fetch(:compiled_asset_path)) desc 'Starts an interactive console.' task :console do From 7f662b05aa5fc3fb8404517ed52208d8acec5ea1 Mon Sep 17 00:00:00 2001 From: Akshay Birajdar Date: Wed, 25 Dec 2019 00:37:44 +0530 Subject: [PATCH 2/3] Update the assets precompile output as per rails 6 --- spec/support/outputs/rails_assets_precompile.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/support/outputs/rails_assets_precompile.txt b/spec/support/outputs/rails_assets_precompile.txt index bebd3a8f..0738de09 100644 --- a/spec/support/outputs/rails_assets_precompile.txt +++ b/spec/support/outputs/rails_assets_precompile.txt @@ -1 +1 @@ -if\ diff\ \-qrN\ ".*/deploy/current/vendor/assets/"\ "\./vendor/assets/"\ 2>/dev/null\ &&\ diff\ \-qrN\ ".*/deploy/current/app/assets/"\ "\./app/assets/"\ 2>/dev/null\s*then\s*echo\ "\-\-\-\-\->\ Skipping\ asset\ precompilation"\s*else\s*echo\ "\-\-\-\-\->\ Precompiling\ asset\ files"\s*RAILS_ENV="production"\ bundle\ exec\ rake\ assets:precompile\s*fi +if\ diff\ \-qrN\ ".*/deploy/current/vendor/assets/"\ "\./vendor/assets/"\ 2>/dev/null\ &&\ diff\ \-qrN\ ".*/deploy/current/app/assets/"\ "\./app/assets/"\ 2>/dev/null\ &&\ diff\ \-qrN\ ".*/deploy/current/app/javascript/"\ "\./app/javascript/"\ 2>/dev/null\s*then\s*echo\ "\-\-\-\-\->\ Skipping\ asset\ precompilation"\s*else\s*echo\ "\-\-\-\-\->\ Precompiling\ asset\ files"\s*RAILS_ENV="production"\ bundle\ exec\ rake\ assets:precompile\s*fi From 5110989c25a88533284cab6322989f382751c09b Mon Sep 17 00:00:00 2001 From: Akshay Birajdar Date: Sat, 14 Aug 2021 10:47:19 +0530 Subject: [PATCH 3/3] Add package.json to asset_dirs --- spec/support/outputs/rails_assets_precompile.txt | 2 +- tasks/mina/rails.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/support/outputs/rails_assets_precompile.txt b/spec/support/outputs/rails_assets_precompile.txt index 0738de09..2c6bc21b 100644 --- a/spec/support/outputs/rails_assets_precompile.txt +++ b/spec/support/outputs/rails_assets_precompile.txt @@ -1 +1 @@ -if\ diff\ \-qrN\ ".*/deploy/current/vendor/assets/"\ "\./vendor/assets/"\ 2>/dev/null\ &&\ diff\ \-qrN\ ".*/deploy/current/app/assets/"\ "\./app/assets/"\ 2>/dev/null\ &&\ diff\ \-qrN\ ".*/deploy/current/app/javascript/"\ "\./app/javascript/"\ 2>/dev/null\s*then\s*echo\ "\-\-\-\-\->\ Skipping\ asset\ precompilation"\s*else\s*echo\ "\-\-\-\-\->\ Precompiling\ asset\ files"\s*RAILS_ENV="production"\ bundle\ exec\ rake\ assets:precompile\s*fi +if\ diff\ \-qrN\ ".*/deploy/current/vendor/assets/"\ "\./vendor/assets/"\ 2>/dev/null\ &&\ diff\ \-qrN\ ".*/deploy/current/app/assets/"\ "\./app/assets/"\ 2>/dev/null\ &&\ diff\ \-qrN\ ".*/deploy/current/app/javascript/"\ "\./app/javascript/"\ 2>/dev/null &&\ diff\ \-qrN\ ".*/deploy/current/package.json"\ "\./package.json"\ 2>/dev/null\s*then\s*echo\ "\-\-\-\-\->\ Skipping\ asset\ precompilation"\s*else\s*echo\ "\-\-\-\-\->\ Precompiling\ asset\ files"\s*RAILS_ENV="production"\ bundle\ exec\ rake\ assets:precompile\s*fi diff --git a/tasks/mina/rails.rb b/tasks/mina/rails.rb index a673bc41..f5b173d7 100644 --- a/tasks/mina/rails.rb +++ b/tasks/mina/rails.rb @@ -6,10 +6,10 @@ set :rake, -> { "#{fetch(:bundle_prefix)} rake" } set :rails, -> { "#{fetch(:bundle_prefix)} rails" } set :compiled_asset_path, ['public/assets', 'public/packs'] -set :asset_dirs, ['vendor/assets/', 'app/assets/', 'app/javascript/'] +set :asset_dirs, ['vendor/assets/', 'app/assets/', 'app/javascript/', 'package.json'] set :migration_dirs, ['db/migrate'] -set :shared_dirs, fetch(:shared_dirs, []).push('log', 'tmp/cache', *fetch(:compiled_asset_path)) +set :shared_dirs, fetch(:shared_dirs, []).push('log', 'tmp/cache', 'node_modules', *fetch(:compiled_asset_path)) desc 'Starts an interactive console.' task :console do