Skip to content

Commit a62e9f9

Browse files
committed
bin/rails stimulus:install
1 parent 796d069 commit a62e9f9

File tree

5 files changed

+24
-0
lines changed

5 files changed

+24
-0
lines changed

app/javascript/application.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
2+
import "controllers"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Application } from "@hotwired/stimulus"
2+
3+
const application = Application.start()
4+
5+
// Configure Stimulus development experience
6+
application.debug = false
7+
window.Stimulus = application
8+
9+
export { application }
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Controller } from "@hotwired/stimulus"
2+
3+
export default class extends Controller {
4+
connect() {
5+
this.element.textContent = "Hello World!"
6+
}
7+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Import and register all your controllers from the importmap via controllers/**/*_controller
2+
import { application } from "controllers/application"
3+
import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"
4+
eagerLoadControllersFrom("controllers", application)

config/importmap.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# Pin npm packages by running ./bin/importmap
22

33
pin "application"
4+
pin "@hotwired/stimulus", to: "stimulus.min.js"
5+
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js"
6+
pin_all_from "app/javascript/controllers", under: "controllers"

0 commit comments

Comments
 (0)