79333010

Date: 2025-01-06 12:29:17
Score: 0.5
Natty:
Report link

It's highly recommended that you switch to cssbundling-rails (and jsbundling-rails) for Bootstrap 5+ on Rails 8 with propshaft as your asset management library. I couldn't find a way to do it without these, although I personally needed SASS support for a different reason.

Some things are configured automatically with bin/rails css:install:sass so start there.

In Gemfile, add:

gem "jsbundling-rails"
gem "cssbundling-rails"

Then run bundle install.

I needed to create app/assets/stylesheets/application.sass.scss

@import "application.bootstrap";
@import "fontawesome";

app/assets/stylesheets/application.bootstrap.scss looks like this:

@import 'bootstrap/scss/bootstrap';
@import 'bootstrap-icons/font/bootstrap-icons';

Ensure you run bin/dev to start your RoR server, as rails server didn't seem to be sufficient anymore.

FontAwesome

For fontawesome support, app/assets/stylesheets/fontawesome.scss looks like this, as per this article: https://www.babar.im/blog/programming/ruby/how-to-use-fontawesome-5-6-with-rails-7-and-propshaft.html

$fa-font-path: "./webfonts";

@import "@fortawesome/fontawesome-free/scss/regular";
@import "@fortawesome/fontawesome-free/scss/brands";
@import "@fortawesome/fontawesome-free/scss/solid";
@import "@fortawesome/fontawesome-free/scss/fontawesome";

You'll also need to create the build:css:fontawesome build step in package.json and run that manually (as explained in the article)

Reasons:
  • Blacklisted phrase (1): this article
  • Blacklisted phrase (0.5): I need
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Nigel Sheridan-Smith