Last active
November 12, 2022 18:44
-
-
Save reinink/8f2556ce9e779838ecc2e878a446d0d6 to your computer and use it in GitHub Desktop.
Inertia and Vite SSR setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createSSRApp, h } from 'vue' | |
import { renderToString } from '@vue/server-renderer' | |
import { createInertiaApp } from '@inertiajs/inertia-vue3' | |
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers'; | |
import createServer from '@inertiajs/server' | |
createServer(page => | |
createInertiaApp({ | |
page, | |
render: renderToString, | |
resolve: (name) => resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue')), | |
setup({ app, props, plugin }) { | |
return createSSRApp({ | |
render: () => h(app, props), | |
}).use(plugin) | |
}, | |
}), | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { defineConfig } from 'vite' | |
import laravel from 'laravel-vite-plugin' | |
import vue from '@vitejs/plugin-vue' | |
export default defineConfig({ | |
plugins: [ | |
laravel({ | |
input: 'resources/js/app.js', | |
ssr: 'resources/js/ssr.js', | |
}), | |
vue({ | |
template: { | |
transformAssetUrls: { | |
base: null, | |
includeAbsolute: false, | |
}, | |
}, | |
}), | |
], | |
ssr: { | |
noExternal: ['@inertiajs/server'], | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment