group stimulus scripts in an asset subfolder

This commit is contained in:
2022-10-01 23:32:05 +02:00
parent aaff9cb482
commit 0953b7ca61
5 changed files with 3 additions and 3 deletions

11
app/assets/stimulus/bootstrap.js vendored Normal file
View File

@@ -0,0 +1,11 @@
import { startStimulusApp } from '@symfony/stimulus-bridge';
// Registers Stimulus controllers from controllers.json and in the controllers/ directory
export const app = startStimulusApp(require.context(
'@symfony/stimulus-bridge/lazy-controller-loader!./controllers',
true,
/\.[jt]sx?$/
));
// register any custom, 3rd party controllers here
// app.register('some_controller_name', SomeImportedController);

View File

@@ -0,0 +1,4 @@
{
"controllers": [],
"entrypoints": []
}

View File

@@ -0,0 +1,16 @@
import { Controller } from '@hotwired/stimulus';
/*
* This is an example Stimulus controller!
*
* Any element with a data-controller="hello" attribute will cause
* this controller to be executed. The name "hello" comes from the filename:
* hello_controller.js -> "hello"
*
* Delete this file or adapt it for your use!
*/
export default class extends Controller {
connect() {
this.element.textContent = 'Hello Stimulus! Edit me in assets/stimulus/controllers/hello_controller.js';
}
}