diff --git a/app/javascript/application.js b/app/javascript/application.js index 390e8db..bb41a78 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -1,2 +1,6 @@ import "initializers" -import "controllers" \ No newline at end of file + +// Import and register all your controllers from the importmap via controllers/**/*_controller +import { application } from "controllers/application" +import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading" +eagerLoadControllersFrom("controllers", application) diff --git a/app/javascript/controllers/application.js b/app/javascript/controllers/application.js index 1213e85..2d5a73e 100644 --- a/app/javascript/controllers/application.js +++ b/app/javascript/controllers/application.js @@ -3,7 +3,7 @@ import { Application } from "@hotwired/stimulus" const application = Application.start() // Configure Stimulus development experience -application.debug = false -window.Stimulus = application +application.debug = true +window.Stimulus = application export { application } diff --git a/app/javascript/controllers/index.js b/app/javascript/controllers/index.js deleted file mode 100644 index 1156bf8..0000000 --- a/app/javascript/controllers/index.js +++ /dev/null @@ -1,4 +0,0 @@ -// Import and register all your controllers from the importmap via controllers/**/*_controller -import { application } from "controllers/application" -import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading" -eagerLoadControllersFrom("controllers", application) diff --git a/config/importmap.rb b/config/importmap.rb index 1b4acba..eb70aba 100644 --- a/config/importmap.rb +++ b/config/importmap.rb @@ -1,9 +1,7 @@ -# Pin npm packages by running ./bin/importmap - pin 'application' pin '@hotwired/turbo-rails', to: 'turbo.min.js' pin '@hotwired/stimulus', to: 'stimulus.min.js' pin '@hotwired/stimulus-loading', to: 'stimulus-loading.js' -pin_all_from 'app/javascript/controllers', under: 'controllers' pin_all_from 'app/javascript/initializers', under: 'initializers' +pin_all_from 'app/javascript/controllers', under: 'controllers'