prerender config

See Guides > Pre-rendering (SSG) for an overview of how to pre-render our app.

By default, pre-rendering is disabled. To enable it:

// vite.config.js

import { ssr } from 'vite-plugin-ssr/plugin'

export default {
  plugins: [
    ssr({
      // Use the default pre-render config:
      prerender: true
      // Deviate from the default pre-render config:
      prerender: {
        partial?: boolean
        noExtraDir?: boolean
        parallel?: boolean | number
        disableAutoRun?: boolean
      }
    })
  ]
}

partial

Optional, default value: false.

Allow only some of our pages to be pre-rendered.

This setting doesn't affect the pre-rendering process: it merely suppresses the warnings when some of our pages cannot be pre-rendered.

vite-plugin-ssr shows a warning that a page cannot be pre-rendered when:

noExtraDir

Optional, default value: false.

Do not create a new directory for each HTML file.

For example, generate dist/client/about.html instead of dist/client/about/index.html.

Generting a directory for each HTML file is the most reliable way for telling Static Hosts the static URL of each static HTML. But some static hosts prefer the other way.

parallel

Optional, default value: os.cpus().length.

Number of concurrent pre-render jobs.

Set to false (or 1) to disable concurrency.

The default value is the fastest, but it may induce high spikes of memory usage.

Disable concurrency if:

  • You encounter JavaScript heap out of memory errors.
  • If pre-rendering takes an abnormal high amount of time. (Caused by the very slow process of memory swapping that kicks-in when memory starts to saturates).

disableAutoRun

Optional, default value: false.

Disable the automatic initiation of the pre-rendering process when running $ vite build.

Use this if you want to programmatically initiate the pre-rendering process instead.

See API > prerender() programmatic.