Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support new SASS processors #271

Merged
merged 2 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ gem 'bootstrap', '~> 5.3.2'

This gem requires a Sass engine, so make sure you have **one** of these two gems in your Gemfile:
- [`dartsass-sprockets`](https://github.com/tablecheck/dartsass-sprockets): Dart Sass engine, recommended but only works for Ruby 2.6+ and Rails 5+
- [`dartsass-rails`](https://github.com/rails/dartsass-rails): Dart Sass engine, recommended for Rails projects that use Propshaft
- [`cssbundling-rails`](https://github.com/rails/cssbundling-rails): External Sass engine
- [`sassc-rails`](https://github.com/sass/sassc-rails): SassC engine, deprecated but compatible with Ruby 2.3+ and Rails 4

Also ensure that `sprockets-rails` is at least v2.3.2.
Expand Down
10 changes: 9 additions & 1 deletion lib/bootstrap/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@
begin
require 'sassc-rails'
rescue LoadError
raise LoadError.new("bootstrap-rubygem requires a Sass engine. Please add dartsass-sprockets or sassc-rails to your dependencies.")
begin
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hate the way these rescues nest, but I can't think of a better way for chaining requires like this.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#272 suggestion

require 'dartsass-rails'
rescue LoadError
begin
require 'cssbundling-rails'
rescue LoadError
raise LoadError.new("bootstrap-rubygem requires a Sass engine. Please add dartsass-sprockets, sassc-rails, dartsass-rails or cssbundling-rails to your dependencies.")
end
end
end
end

Expand Down