class HotwiredComponent::InstallGenerator
Public Instance Methods
add_application_component()
click to toggle source
def install_hotwired_rails
rake "hotwire:install"
end
# File lib/generators/hotwired_component/install/install_generator.rb, line 9 def add_application_component template "application_component.rb.erb", "app/components/application_component.rb" end
add_component_controllers()
click to toggle source
# File lib/generators/hotwired_component/install/install_generator.rb, line 14 def add_component_controllers append_to_file "app/javascript/controllers/index.js" do <<~JAVASCRIPT context = require.context("../../components", true, /_controller\.js$/) application.load(definitionsFromContext(context)) JAVASCRIPT end end
update_webpacker_config()
click to toggle source
# File lib/generators/hotwired_component/install/install_generator.rb, line 23 def update_webpacker_config gsub_file "config/webpacker.yml", "additional_paths: [", "additional_paths: [\"app/components\"" end