Skip to content

SSR using vitejs #1038

Answered by ajnsn
ibrunotome asked this question in Help (Vue)
Jan 7, 2022 · 1 comments · 9 replies
Discussion options

You must be logged in to vote

Hey @ibrunotome

I am also still trying out things regarding SSR in combination with Vite, but this seems to work:

vite.ssr.config.js

import { defineConfig } from 'vite';
import { resolve } from 'path';
import vue from '@vitejs/plugin-vue';

export default defineConfig(() => ({
    publicDir: false,
    build: {
        ssr: true,
        target: 'node17',
        outDir: 'public/build-ssr',
        rollupOptions: {
            input: 'resources/js/ssr.js',
        },
    },
    resolve: {
        alias: {
            '@': resolve(__dirname, 'resources/js'),
        },
    },
    plugins: [vue()],
}));

ssr.js

import { createSSRApp, h } from 'vue';
import { renderToString } from '@vue/serve…

Replies: 1 comment 9 replies

Comment options

You must be logged in to vote
9 replies
@ibrunotome
Comment options

@ajnsn
Comment options

@ibrunotome
Comment options

@secondmanveran
Comment options

@ibrunotome
Comment options

Answer selected by ibrunotome
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants