Skip to content

Commit

Permalink
Conditionally generate assets during setup
Browse files Browse the repository at this point in the history
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
  • Loading branch information
stevepolitodesign committed Feb 9, 2024
1 parent d283063 commit 52daa95
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/generators/templates/setup/bin_setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 52daa95

Please sign in to comment.