Rails 7: ImportMap-Rails with Bootstrap, Stimulus, Turbo (Quick Setup)

Here we will do a manual setup for ImportMap-Rails starting from rails new --skip-javascript. Please note that these are the step-by-step instructions for helping you start with a brand new Rails 7 app, but they are more steps than the standard Rails 7 install, which runs the ImportMap, Turbo, and Stimulus JS installers for you.

These quick instructions are for you to get going quickly, but they do no walk you through the step-by-step of verifying each component of the stack you are using. If you want to get a more in-depth understanding of each piece of the stack, refer to this post instead.

Remember for an ImportMap-Rails app you will continue using rails server to start your server, as there is no auxiliary SASS watcher running in the background.

1/ New Rails 7 App

rails new MyTestApp --skip-javascript

*commit changes*

2/ add to Gemfile

gem "importmap-rails"
gem "turbo-rails"

run bundle install

*commit changes*

3/ Install ImportMap-Rails

Run rails importmap:install

*commit changes*

4/ Install Turbo

run rails turbo:install

*commit changes*

5/ Install Stimulus

run rails stimulus:install

6/ Pin Bootstrap Using Importmap-Rails

./bin/importmap pin bootstrap@5.1.3
./bin/importmap pin @popperjs/core@2.11.2