Custom parts javascript? #1101
-
When writing custom parts, what's the way to get javascript files (such as stimulus controllers) included properly in the import map used by the Spina Engine? |
Beta Was this translation helpful? Give feedback.
Answered by
Bramjetten
Sep 12, 2022
Replies: 1 comment 1 reply
-
This is how we do that in Spina Pro: # engine.rb
module Spina
module Pro
class Engine < ::Rails::Engine
# ...
initializer "spina.pro.assets.assets" do |app|
# Add pro Stimulus controllers to Spina's importmap
Spina.config.importmap.draw do |paths|
pin_all_from Spina::Pro::Engine.root.join("app/assets/javascripts/spina/pro/controllers"), under: "controllers", to: "spina/pro/controllers"
pin_all_from Spina::Pro::Engine.root.join("app/assets/javascripts/spina/pro/libraries"), under: "libraries", to: "spina/pro/libraries"
end
# Add assets manifest to assets.precompile
app.config.assets.precompile += %w(spina/pro/manifest.js)
end
end
end
end |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Bramjetten
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is how we do that in Spina Pro: