You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+36-13Lines changed: 36 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -140,20 +140,43 @@ Importmap::pin("@hotwired/stimulus-loading", to: "vendor/stimulus-laravel/stimul
140
140
141
141
### Vite Steps
142
142
143
-
2. Create a `resources/js/controllers/index.js` and load your controllers from there:
143
+
1. Create a `resources/js/controllers/index.js` and chose if you want to register your controllers manually or not:
144
144
145
-
```js
146
-
// This file is auto-generated by `php artisan stimulus:install`
147
-
// Run that command whenever you add a new controller or create them with
148
-
// `php artisan stimulus:make controllerName`
145
+
#### Register controllers manually
146
+
147
+
```js
148
+
// This file is auto-generated by `php artisan stimulus:install`
149
+
// Run that command whenever you add a new controller or create them with
150
+
// `php artisan stimulus:make controllerName`
149
151
150
-
import { application } from'../libs/stimulus'
152
+
import { application } from'../libs/stimulus'
151
153
152
-
importHelloControllerfrom'./hello_controller'
153
-
application.register('hello', HelloController)
154
-
```
154
+
importHelloControllerfrom'./hello_controller'
155
+
application.register('hello', HelloController)
156
+
```
157
+
158
+
#### Register controllers automatically
159
+
160
+
If you prefer to automatially register your controllers you can use the [`stimulus-vite-helpers`](https://www.npmjs.com/package/stimulus-vite-helpers) NPM package.
161
+
162
+
```js
163
+
// resources/js/controllers/index.js
164
+
165
+
import { application } from '../libs/stimulus'
166
+
import { registerControllers } from 'stimulus-vite-helpers'
155
167
156
-
3. Create `resources/js/libs/stimulus.js` with the following content:
0 commit comments