Class: Blacklight::Assets::SprocketsGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Blacklight::Assets::SprocketsGenerator
- Defined in:
- lib/generators/blacklight/assets/sprockets_generator.rb
Instance Method Summary collapse
-
#add_javascript_dependencies ⇒ Object
This could be skipped if you want to use webpacker.
-
#appease_sprockets4 ⇒ Object
Remove the empty generated app/assets/images directory.
- #assets ⇒ Object
Instance Method Details
#add_javascript_dependencies ⇒ Object
This could be skipped if you want to use webpacker
9 10 11 12 |
# File 'lib/generators/blacklight/assets/sprockets_generator.rb', line 9 def add_javascript_dependencies gem 'bootstrap', [:'bootstrap-version'].presence gem 'jquery-rails' if bootstrap_4? # Bootstrap 4 has a dependency on jquery end |
#appease_sprockets4 ⇒ Object
Remove the empty generated app/assets/images directory. Without doing this, the default Sprockets 4 manifest will raise an exception.
17 18 19 20 21 22 23 |
# File 'lib/generators/blacklight/assets/sprockets_generator.rb', line 17 def appease_sprockets4 return if Rails.version > '7' || Sprockets::VERSION < '4' append_to_file 'app/assets/config/manifest.js', "\n//= link application.js" append_to_file 'app/assets/config/manifest.js', "\n//= link blacklight/manifest.js" empty_directory 'app/assets/images' end |
#assets ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/generators/blacklight/assets/sprockets_generator.rb', line 25 def assets create_file 'app/assets/stylesheets/blacklight.scss' do <<~CONTENT @import 'bootstrap'; @import 'blacklight/blacklight'; CONTENT end gem "sassc-rails", "~> 2.1" if Rails.version > '7' # Ensure this method is idempotent return if has_blacklight_assets? create_file 'app/assets/javascripts/application.js' do <<~CONTENT //= require rails-ujs #{'//= require jquery3' if bootstrap_4?} // Required by Blacklight //= require popper //= require bootstrap //= require blacklight/blacklight CONTENT end end |