Adding Bootstrap to Rails 7 Link to heading
Reference: How to Install Bootstrap in Rails 7 using importmaps without node.js
Instructions Link to heading
-
Add the following to
Gemfile
:gem "bootstrap" gem "sassc-rails"
Then
bundle install
-
Rename
application.css
toapplication.scss
-
Import Bootstrap styles in
app/assets/stylesheets/application.scss
:@import "bootstrap";
-
Include bootstrap in your
app/javascript/application.js
:import "popper" import "bootstrap"
-
Go to
config/importmap.rb
and add the following:pin "popper", to: 'popper.js', preload: true pin "bootstrap", to: 'bootstrap.min.js', preload: true
-
Add the following to
config/initializers/assets.rb
:Rails.application.config.assets.precompile += %w( bootstrap.min.js popper.js)