From 52daa95c9e41c5d41a030ee106544fab07fa899f Mon Sep 17 00:00:00 2001 From: Steve Polito Date: Fri, 9 Feb 2024 09:19:33 -0500 Subject: [PATCH] Conditionally generate assets during setup Clobber and precompile assets during setup if using [Sprockets][]. This is helpful in cases where one might switch branches frequently, which can result in broken assets. [Sprockets]: https://github.com/rails/sprockets --- lib/generators/templates/setup/bin_setup.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/generators/templates/setup/bin_setup.rb b/lib/generators/templates/setup/bin_setup.rb index 823bd5bc1..502f518c1 100755 --- a/lib/generators/templates/setup/bin_setup.rb +++ b/lib/generators/templates/setup/bin_setup.rb @@ -43,6 +43,11 @@ def using_node? puts "\n== Preparing database and adding development seed data ==" system! "bin/rails dev:prime" + if Rake::Task.task_defined?("assets:clobber") && Rake::Task.task_defined("assets:precompile") + puts "\n== Generating assets ==" + system! "bin/rails assets:clobber assets:precompile" + end + # https://github.com/rails/rails/pull/47719/files puts "\n== Setup test environment ==" system! "bin/rails test:prepare"