- Make sure
sprockets-rails
is installed. This wasn't the case when using Rails 7.0.0.alpha2
. I think this was the most important step.
# Gemfile
gem "sprockets-rails"
- Add
preload: true
to the necessary assets. I'm just copying the default Rails 7.0.0
config. This differs from the original Rails 7.0.0.alpha2
install.
# config/importmap.rb
# Pin npm packages by running ./bin/importmap
pin "application", preload: true
pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true
pin "@hotwired/stimulus", to: "stimulus.min.js", preload: true
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true
pin_all_from "app/javascript/controllers", under: "controllers"
- Clear the cache. I'm not sure if this is necessary, but it migt help helped.