Skip to content

Commit

Permalink
Allow Blacklight to define Stimulus controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Feb 6, 2023
1 parent f4faf72 commit 2b9ff2b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/importmap.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true

pin_all_from File.expand_path("../app/javascript/blacklight", __dir__), under: "blacklight"
pin_all_from File.expand_path("../app/javascript/controllers", __dir__), under: "controllers"
15 changes: 15 additions & 0 deletions lib/railties/blacklight.rake
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,18 @@ namespace :blacklight do
end
end
end

if Rake::Task.task_defined?('stimulus:manifest:display')
Rake::Task['stimulus:manifest:display'].enhance do
puts Stimulus::Manifest.generate_from(Blacklight::Engine.root.join("app/javascript/controllers")).join("\n").gsub('./blacklight/', 'blacklight-frontend/app/javascript/controllers/blacklight/')
end
end

if Rake::Task.task_defined?('stimulus:manifest:update')
Rake::Task['stimulus:manifest:update'].enhance do
manifest = Stimulus::Manifest.generate_from(Blacklight::Engine.root.join("app/javascript/controllers")).join("\n").gsub('./blacklight/', 'blacklight-frontend/app/javascript/controllers/blacklight/')
File.open(Rails.root.join("app/javascript/controllers/index.js"), "a+") do |index|
index.puts manifest
end
end
end
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"not IE 11"
],
"dependencies": {
"@hotwired/stimulus": "^3.2.1",
"bootstrap": ">=4.3.1 <6.0.0"
}
}

0 comments on commit 2b9ff2b

Please sign in to comment.