Config

Most configuration options are covered in the sections relating to them.

Below is a quick reference of all options and their default values.

General

dev

Whether or not to run Vite's development server
process.env.NODE​_ENV !== 'production'
root

The Vite client app's source root
process.cwd()
renderer

Renderer adapter
No default value

Hydration

hydration.global

Global Data hydration key
'$global'
hydration.payload

Route Payloads hydration key
'$payload'
hydration.data

Isomorphic Data hydration key
'$data'

Deployment

build

If true, triggers Vite build and exits
process.argv.includes('build')

Enables node app.js build by default
generate.enabled

If true, triggers Vite build with prerendered paths included (static generation) and exits
process.argv.includes('generate')

Enables node app.js generate by default
generate.paths

Callback function called to determine which paths should be prerendered in the initial statically generated build (more can be added via the live generate server)
No default value

If none provided, static paths are inferred from the routes array
generate.server.enabled

If true, triggers Vite build with prerendered paths included (static generation) and starts the live static generation server API
process.argv.includes('generate-server')

Enables node app.js generate-server by default
generate.server.generated

Callback function called when an URL gets generated (or regenerated) via the live static generation server API
No default value

Vite

As explained in Vite's documentation, a Vite SSR application requires you to build both a client and a server bundle. Since fastify-vite makes your Fastify server recognize build and generate commands, it also lets you configure client and server entry points.

TIP

In plain Vite SSR projects, the server entry point is not something you configure, but rather pass in to Vite's build CLI command, while the client entry point is the main JavaScript file you reference from index.html — even though the official documentation refers to index.html as the entry point of your app. This is probably because the generated index.html is what is delivered to the browser if you're not performing SSR — but if you are, it gets replaced by what is dynamically generated (SSR) from the server.

entry.server

Vite server entry point
Default value provided by renderer adapter

Conventionally set as /entry/server.<extension>
entry.client

Vite client entry point
Default value provided by renderer adapter

Conventionally set as /entry/client.<extension>

fastify-vite tries to intefere as little as possible in configuring your Vite apps.

So if you want to just have vite.config.js for all Vite settings, that will just work as expected.

However, you can also use the vite option:

vite

Vite configuration options
Default value provided by renderer adapter

You must use one or the other, as there's no way to reliably merge the order of plugins if there are two sources of configuration.