Skip to content

Commit 2b9ff2b

Browse files
committed
Allow Blacklight to define Stimulus controllers
1 parent f4faf72 commit 2b9ff2b

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

config/importmap.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# frozen_string_literal: true
22

33
pin_all_from File.expand_path("../app/javascript/blacklight", __dir__), under: "blacklight"
4+
pin_all_from File.expand_path("../app/javascript/controllers", __dir__), under: "controllers"

lib/railties/blacklight.rake

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,18 @@ namespace :blacklight do
119119
end
120120
end
121121
end
122+
123+
if Rake::Task.task_defined?('stimulus:manifest:display')
124+
Rake::Task['stimulus:manifest:display'].enhance do
125+
puts Stimulus::Manifest.generate_from(Blacklight::Engine.root.join("app/javascript/controllers")).join("\n").gsub('./blacklight/', 'blacklight-frontend/app/javascript/controllers/blacklight/')
126+
end
127+
end
128+
129+
if Rake::Task.task_defined?('stimulus:manifest:update')
130+
Rake::Task['stimulus:manifest:update'].enhance do
131+
manifest = Stimulus::Manifest.generate_from(Blacklight::Engine.root.join("app/javascript/controllers")).join("\n").gsub('./blacklight/', 'blacklight-frontend/app/javascript/controllers/blacklight/')
132+
File.open(Rails.root.join("app/javascript/controllers/index.js"), "a+") do |index|
133+
index.puts manifest
134+
end
135+
end
136+
end

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"not IE 11"
3131
],
3232
"dependencies": {
33+
"@hotwired/stimulus": "^3.2.1",
3334
"bootstrap": ">=4.3.1 <6.0.0"
3435
}
3536
}

0 commit comments

Comments
 (0)