Extending Inertia + Vue package from Laravel application
Hi, I am building something similar to Laravel Nova where you have a packaged that provides some administrative functionality. It's build with Inertiajs for routing and Vue 3 as js framework. Original idea was to be able to provide different applications using the package an ability to extend the functionality by providing their own routes and controllers and components that can be registered with the package script.
so I would have something like this in the application
// resources/js/admin.js
import CustomPageComponent from './components/CustomPageComponent.vue'
document.addEventListener('PackageScriptReady', function() {
PackageScript.inertia('CustomPageComponent', CustomPageComponent)
})
This works and I can see my package script loading this component but I ran into several issues:
- I cannot use any third-party library like element-plus in my CustomPageComponent - it gives me
useContexterror which I understand is because when my application script is building a component - it doesn't have app context. - importing my package components works only if they don't have any imports on their own - every internal import is treated by application as relative to the application structure - not package's (in vendor)
So... does anyone know if there's a way to develop a component without wrapping it in createApp() (i.e. injecting existing app context?).
and is there a proper way to use components (in vendor package) from within application so that all the dependencies are resolved properly?
Thanks
Please or to participate in this conversation.