Class: Blacklight::Assets::ImportmapGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Blacklight::Assets::ImportmapGenerator
- Defined in:
- lib/generators/blacklight/assets/importmap_generator.rb
Instance Method Summary collapse
Instance Method Details
#add_stylesheet ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/generators/blacklight/assets/importmap_generator.rb', line 42 def add_stylesheet if File.exist? 'app/assets/stylesheets/application.bootstrap.scss' append_to_file 'app/assets/stylesheets/application.bootstrap.scss' do <<~CONTENT @import url("blacklight.css"); CONTENT end else append_to_file 'app/assets/stylesheets/application.css' do <<~CONTENT /* *= require blacklight */ @import url(https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css); CONTENT end end end |
#append_blacklight_javascript ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/generators/blacklight/assets/importmap_generator.rb', line 26 def append_blacklight_javascript # This may already be present if rails new was invoked with `--css bootstrap' append_to_file 'app/javascript/application.js' do <<~CONTENT import * as bootstrap from "bootstrap" CONTENT end append_to_file 'app/javascript/application.js' do <<~CONTENT import githubAutoCompleteElement from "@github/auto-complete-element" import Blacklight from "blacklight-frontend" CONTENT end end |
#import_javascript_assets ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/generators/blacklight/assets/importmap_generator.rb', line 8 def import_javascript_assets append_to_file 'config/importmap.rb' do <<~CONTENT pin "@github/auto-complete-element", to: "https://cdn.skypack.dev/@github/auto-complete-element" pin "@popperjs/core", to: "https://ga.jspm.io/npm:@popperjs/core@2.11.6/dist/umd/popper.min.js" pin "bootstrap", to: "https://ga.jspm.io/npm:bootstrap@#{(defined?(Bootstrap) && Bootstrap::VERSION) || '5.3.3'}/dist/js/bootstrap.js" CONTENT end return unless defined?(Sprockets) append_to_file 'app/assets/config/manifest.js' do <<~CONTENT //= link blacklight/manifest.js CONTENT end end |