add support for extension vite plugin loading, add vue setup hook for extensions

This commit is contained in:
Gregor Vostrak
2024-04-23 22:37:30 +02:00
parent 2f0ad0eb44
commit a3196c4964
5 changed files with 70 additions and 40 deletions

View File

@@ -18,11 +18,14 @@ createInertiaApp({
import.meta.glob<DefineComponent>('./Pages/**/*.vue')
),
setup({ el, App, props, plugin }) {
createApp({ render: () => h(App, props) })
.use(plugin)
.use(pinia)
.use(ZiggyVue)
.mount(el);
const app = createApp({ render: () => h(App, props) });
// currently only one vue app setup hook is supported
if (window.vueAppSetupHook) {
window.vueAppSetupHook(app);
}
app.use(plugin).use(pinia).use(ZiggyVue).mount(el);
},
progress: {

View File

@@ -2,11 +2,13 @@ import { PageProps as InertiaPageProps } from '@inertiajs/core';
import { AxiosInstance } from 'axios';
import ziggyRoute from 'ziggy-js';
import { PageProps as AppPageProps } from './';
import type { App } from 'vue';
declare global {
interface Window {
axios: AxiosInstance;
initialDataLoaded: boolean;
vueAppSetupHook?: (app: App) => void;
}
let route: typeof ziggyRoute;

View File

@@ -23,7 +23,7 @@
<!-- Scripts -->
@routes
@vite(['resources/js/app.ts', "resources/js/Pages/{$page['component']}.vue"])
@vite(\Nwidart\Modules\Module::getAssets())
@inertiaHead
</head>
<body class="font-sans antialiased">