diff options
author | Hartley McGuire <hartley.mcguire@shopify.com> | 2022-07-13 21:59:42 +0300 |
---|---|---|
committer | Gleb Mazovetskiy <glex.spb@gmail.com> | 2022-07-25 23:46:24 +0300 |
commit | 49a70a4933a1e3dbf8ec06e29fc2ed170f25ccd7 (patch) | |
tree | 330318fbe70e66f5761056d4191c91a09f40b298 | |
parent | 003c627ea7589dbbd8aeff030353b8c5decb6fbf (diff) |
Add Importmaps section to README
As importmap-rails is the default way to use javascript starting in
Rails 7, this should help users wanting to use Bootstrap without using
node.
-rw-r--r-- | README.md | 26 |
1 files changed, 23 insertions, 3 deletions
@@ -1,11 +1,12 @@ # Bootstrap Ruby Gem [![Build Status](https://travis-ci.org/twbs/bootstrap-rubygem.svg?branch=master)](https://travis-ci.org/twbs/bootstrap-rubygem) [![Gem](https://img.shields.io/gem/v/bootstrap.svg)](https://rubygems.org/gems/bootstrap) -[Bootstrap 5][bootstrap-home] ruby gem for Ruby on Rails (*Sprockets*) and Hanami (formerly Lotus). +[Bootstrap 5][bootstrap-home] ruby gem for Ruby on Rails (*Sprockets*/*Importmaps*) and Hanami (formerly Lotus). For Sass versions of Bootstrap 3 and 2 see [bootstrap-sass](https://github.com/twbs/bootstrap-sass) instead. -**Ruby on Rails 6 Note:**: -With the release of Rails 6 there have been some minor changes made to the default configuration for The Asset Pipeline. In specific, by default _Sprockets no longer processes JavaScript_ and instead Webpack is set as the default. The `twbs/bootstrap-rubygem` is for use with Sprockets not Webpack. +**Ruby on Rails Note**: Newer releases of Rails have added additional ways for +assets to be processed. The `twbs/bootstrap-rubygem` is for use with Importmaps +or Sprockets, but not Webpack. ## Installation @@ -58,6 +59,25 @@ Bootstrap tooltips and popovers depend on [popper.js] for positioning. The `bootstrap` gem already depends on the [popper_js](https://github.com/glebm/popper_js-rubygem) gem. +#### Importmaps + +You can pin either `bootstrap.js` or `bootstrap.min.js` in `config/importmap.rb` +as well as `popper.js`: + +```ruby +pin "bootstrap", to: "bootstrap.min.js", preload: true +pin "@popperjs/core", to: "popper.js", preload: true +``` + +Whichever files you pin will need to be added to `config.assets.precompile`: + +```ruby +# config/initializers/assets.rb +Rails.application.config.assets.precompile += %w(bootstrap.min.js popper.js) +``` + +#### Sprockets + Add Bootstrap dependencies and Bootstrap to your `application.js`: ```js |