Skip to content

Instantly share code, notes, and snippets.

@stevepolitodesign
Created December 26, 2021 14:23
Show Gist options
  • Save stevepolitodesign/2d166f394f7ffc4434c3dcebfbd440f6 to your computer and use it in GitHub Desktop.
Save stevepolitodesign/2d166f394f7ffc4434c3dcebfbd440f6 to your computer and use it in GitHub Desktop.
Fix Import Maps from Rails 7.0.0.alpha2 to Rails 7.0.0
  1. 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"
  1. 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"
  1. Clear the cache. I'm not sure if this is necessary, but it migt help helped.
rails tmp:clear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment