Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mihir-kumar-thakur/84aff917a3f1449c4bb8084e5bcfcf17 to your computer and use it in GitHub Desktop.
Save mihir-kumar-thakur/84aff917a3f1449c4bb8084e5bcfcf17 to your computer and use it in GitHub Desktop.
Bootstrap 5 Integration with rails 6.1

Install following packages with yarn

yarn add bootstrap
yarn add @popperjs/core

Next, we need to import bootstraps to our application.js

import "bootstrap"
import "../stylesheets/application"

Import bootstrap css to - app/javascript/stylesheets/application.scss

@import '~bootstrap/scss/bootstrap';

Next add following to app/views/layouts/application.html.erb

<%= stylesheet_pack_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>

Now add following config/webpack/environment.js

const webpack = require('webpack')

environment.plugins.append('Provide', new webpack.ProvidePlugin({
  Popper: ['@popperjs/core', 'default']
}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment