6

After getting a project setup in rails 5.1 with --webpack=react option should I install the bootstrap gem? or use yarn add bootstrap? Or would I need both if I'm using rails and react components throughout a project?

Also, are there pros and cons of either method?

tk421
  • 5,775
  • 6
  • 23
  • 34
Luke Popwell
  • 381
  • 1
  • 3
  • 15

1 Answers1

4

It depends on where you want to use Bootstrap.

In the case you need it, in a app/views/*/*.html.erb for instance, you would need the gem, and require it in the Rails assets pipeline in the app/assets/stylesheets/application.scss and same for JavaScript file.

But as you mentioned you created your Rails application with --webpack=react, I guess you'd like to use Bootstrap in your client side application, so the app/javascript folder and not the Rails assets (app/assets). In this case you will have to install it using yarn.

You have to see the app/assets as the "old way", or the non-javascript framework way (which isn't fully true as you have some gems to install React or AngularJs etc...), and you should see app/javascript the new way, with webpacker, so using a JavaScript framework and being an app 100% JavaScript (while in the assets you'll use some .erb files).

ZedTuX
  • 2,859
  • 3
  • 28
  • 58