-
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Reusable Bundle] Multiple controllers directories #83
Comments
Hi! After calling startStimulusApp() for one directory, you get an Application object back. You can use the normal stimulus functionality to load further contexts - use this package https://github.com/hotwired/stimulus-webpack-helpers I hope that helps! |
Hi @weaverryan, At the end, here's what I've put with full path: import { startStimulusApp } from '@symfony/stimulus-bridge';
import { definitionsFromContext } from "@hotwired/stimulus-webpack-helpers"
// 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,
/\.(j|t)sx?$/
));
const myBundleContext = require.context(
"../lib/my-bundle/assets/controllers",
true,
/\.(j|t)sx?$/
)
app.load(definitionsFromContext(myBundleContext )) I don't know why but,
|
Question
Is there a way to add multiple
controllers
directories and import them automatically?Context
We have an internal reusable bundle to share logic between ours Symfony projects.
Here is the structure:
What should be a good approach
1.In the App controller.json add a way to import other bootstrap.js
Like:
2.Add multiple context when calling a startStimulusApp
stimulus-bridge/src/index.ts
Line 20 in d58dc50
What I have tried
Looking at Symfony UX how they import controllers, it uses
packages.json
.Trying to make it work for our reusable bundle I've ended up like this:
Problems
Error at compile, ask to enable TypeScriptLoader or it is already the case
We need to declare each controller is this file.
In the app project import each controller inside the
controller.json
.We have to declare a
main
controller andtypes
?The text was updated successfully, but these errors were encountered: