@@ -87,25 +87,26 @@ composer require hotwired-laravel/stimulus-laravel
87
87
2 . Create ` resources/js/controllers/index.js ` and load your controllers like this:
88
88
89
89
``` js
90
- import { application } from ' libs/stimulus'
90
+ import { Stimulus } from ' libs/stimulus'
91
91
92
92
// Eager load all controllers defined in the import map under controllers/**/*_controller
93
93
import { eagerLoadControllersFrom } from ' @hotwired/stimulus-loading'
94
- eagerLoadControllersFrom (' controllers' , application )
94
+ eagerLoadControllersFrom (' controllers' , Stimulus )
95
95
```
96
96
97
97
3 . Create a ` resources/js/libs/stimulus.js ` with the following content:
98
98
99
99
``` js
100
100
import { Application } from ' @hotwired/stimulus'
101
101
102
- const application = Application .start ()
102
+ const Stimulus = Application .start ()
103
103
104
104
// Configure Stimulus development experience
105
- application .debug = false
106
- window .Stimulus = application
105
+ Stimulus .debug = false
107
106
108
- export { application }
107
+ window .Stimulus = Stimulus
108
+
109
+ export { Stimulus }
109
110
```
110
111
111
112
4 . Create a ` resources/js/libs/index.js ` file with the following content (or add it to an existing file if you have one):
@@ -149,10 +150,10 @@ Importmap::pin("@hotwired/stimulus-loading", to: "vendor/stimulus-laravel/stimul
149
150
// Run that command whenever you add a new controller or create them with
150
151
// `php artisan stimulus:make controllerName`
151
152
152
- import { application } from ' ../libs/stimulus'
153
+ import { Stimulus } from ' ../libs/stimulus'
153
154
154
155
import HelloController from ' ./hello_controller'
155
- application .register (' hello' , HelloController)
156
+ Stimulus .register (' hello' , HelloController)
156
157
```
157
158
158
159
#### Register controllers automatically
@@ -162,12 +163,12 @@ Importmap::pin("@hotwired/stimulus-loading", to: "vendor/stimulus-laravel/stimul
162
163
` ` ` js
163
164
// resources/js/controllers/index.js
164
165
165
- import { application } from '../libs/stimulus'
166
+ import { Stimulus } from '../libs/stimulus'
166
167
import { registerControllers } from 'stimulus-vite-helpers'
167
168
168
169
const controllers = import.meta.glob('./**/*_controller.js', { eager: true })
169
170
170
- registerControllers(application , controllers)
171
+ registerControllers(Stimulus , controllers)
171
172
` ` `
172
173
173
174
And install the NPM package:
@@ -181,13 +182,14 @@ Importmap::pin("@hotwired/stimulus-loading", to: "vendor/stimulus-laravel/stimul
181
182
` ` ` js
182
183
import { Application } from '@hotwired/stimulus'
183
184
184
- const application = Application.start()
185
+ const Stimulus = Application.start()
185
186
186
187
// Configure Stimulus development experience
187
- application.debug = false
188
- window.Stimulus = application
188
+ Stimulus.debug = false
189
+
190
+ window.Stimulus = Stimulus
189
191
190
- export { application }
192
+ export { Stimulus }
191
193
` ` `
192
194
193
195
3. Create a ` resources/js/libs/index.js` file (if it doesn' t exist) and add the following line to it:
0 commit comments