Skip to content

Commit

Permalink
utilizing bootstrap gem pick your own sass library code
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Chan committed Jul 13, 2024
1 parent 0babc0f commit d6b11c4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ gemspec
gem 'rails'
gem 'i18n-tasks'

# For development; when running as a library, you can pick your own sass compiler
gem 'dartsass-sprockets'

eval_gemfile './shared.gemfile'
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ Add [![Gem Version][gem-badge]][gem] to Gemfile:
gem 'rails_email_preview', '~> 2.2.3'
```

This gem requires a Sass engine, please ensure you have **one** of these 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

Add an initializer and the routes:

```console
Expand Down
20 changes: 19 additions & 1 deletion lib/rails_email_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,25 @@
require 'rails_email_preview/delivery_handler'
require 'rails_email_preview/view_hooks'

require 'dartsass-sprockets'
# sass engine loader
begin
require 'dartsass-sprockets'
rescue LoadError
begin
require 'sassc-rails'
rescue LoadError
begin
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

require 'request_store'
require 'turbolinks'
require 'pathname'
Expand Down
1 change: 0 additions & 1 deletion rails_email_preview.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Gem::Specification.new do |s|
end

s.add_dependency 'rails', '>= 4.2'
s.add_dependency 'dartsass-sprockets'
s.add_dependency 'turbolinks'
s.add_dependency 'request_store'

Expand Down

0 comments on commit d6b11c4

Please sign in to comment.