I tried to install bootstrap 5 in existing Rails 7 application. The keyword "existing" is very important because for a new application you can try following.
Anyway, coming back to our existing Rail 7 application that I had already built.
First I followed instructions using gem cssbundling-rails, but it was not successful 100%.
So I opened an issue.
DHH himself replied, I am so elated. Honestly, I did not understand what was told but I figured out that I had to install gem jsbundling-rails.
Here is how I was able to fix it.
Add following 2 gems to the gemfile.
gem 'cssbundling-rails' # Install bootstrap 5
app/assets/config/manifest.js file should have only the following. (It had 2 extra lines which I had to delete because I was getting errors).
//= link_tree ../images
//= link_tree ../builds
Most importatnt step is as follows: (I was getting errors).
For whatever installation I tried earlier there is still a file config/importmap.rb But I think it is useless now, once I removed the code above.
I will have to investigate how to use importmap, but for the time being I am going to keep config/importmap.rb as it is in the codebase.
Start the server as
I fixed the code and then pushed it to GitHub. Yey!!
Note: I found out the following.
In the rails 7, the new way of running the server is to execute ./bin/dev command. This will spin up few processes, that includes — starts of the the server, and watcher process that observes the CSS an JS files.