RobertBoes / sidecar-inertia-vite

A Sidecar function to run Inertia server-side rendering with Vite on Lambda.
MIT License
17 stars 7 forks source link

The command "'npx' '--yes' '@vercel/ncc' 'build' 'bootstrap/ssr/ssr.mjs' '--out=bootstrap/sidecar-ssr'" failed. #6

Closed Tahiry-MO closed 7 months ago

Tahiry-MO commented 7 months ago

For some reason I cannot got past this issue. Is there something I missed? - Thanks.

`The command "'npx' '--yes' '@vercel/ncc' 'build' 'bootstrap/ssr/ssr.mjs' '--out=bootstrap/sidecar-ssr'" failed.

Exit Code: 1(General error)`

1stevengrant commented 6 months ago

@Tahiry-MO how did you resolve this?

Tahiry-MO commented 5 months ago

@Tahiry-MO how did you resolve this?

I am not sure which changes really contributed to the fix but I added this into my vite.config.js:

build: { rollupOptions: { output: { entryFileNames: '[name].mjs' } } },

my ssr.js was also misconfigured initially:

import { createInertiaApp, Head, Link } from '@inertiajs/vue3'
import { renderToString } from '@vue/server-renderer'
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers'
import { createSSRApp, h } from 'vue'
import { ZiggyVue } from '../../vendor/tightenco/ziggy/dist/vue.m'

export async function handler (page) {
    return await createInertiaApp({
        page,
        render: renderToString,
        title: (title) => `${title}`,
        resolve: name =>
            resolvePageComponent(
                `./Pages/${name}.vue`,
                import.meta.glob('./Pages/**/*.vue',
                    { eager: false })
            ),
        setup ({ App, props, plugin }) {
            return createSSRApp({
                render: () => h(App, props)
            }).use(plugin)
                .use(ZiggyVue, {
                    ...page.props.ziggy,
                    location: new URL(page.props.ziggy.location)
                })
                .component('Link', Link)
                .component('Head', Head)
        }
    })
}