SSR with Inertia, Vue, Vite, and vue-instantsearch #43417
-
I want to get SSR working for my inertia+vue app using vue instantsearch. When I try to run my built ssr.js file. I get this error:
My ssr.js file: createServer((page) => createInertiaApp({
page,
render: renderToString,
resolve: name => resolvePageComponent(`./${name}.vue`, import.meta.glob('./**/*.vue', {}))
.then(({default: page}) => {
if(page.layout === undefined) {
page.layout = Layout
}
return page;
}),
setup({ app, props, plugin }) {
return createSSRApp({
render: () => h(app, props),
}).use(plugin)
},
})) Is there a workaround or some way to exclude my search pages from ssr? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Are you using Vite? |
Beta Was this translation helpful? Give feedback.
-
Sorry I figured it out and forgot to come back here. I updated to Vite 3 and updated the laravel plugin to the latest. Finally I added several npm packages to ssr.noExternal in my vite config. 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,
},
},
}),
],
resolve: {
alias: {
'@': '/resources/js'
}
},
ssr: {
noExternal: [
'@inertiajs/server',
'algoliasearch',
'instantsearch.js',
'vue-instantsearch',
],
}
}); |
Beta Was this translation helpful? Give feedback.
Sorry I figured it out and forgot to come back here. I updated to Vite 3 and updated the laravel plugin to the latest. Finally I added several npm packages to ssr.noExternal in my vite config.
My vite.config.ts file now looks like this: