diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index 6abf1a975dd849..3e3ef91ec2b618 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -1301,9 +1301,10 @@ export async function resolveConfig( setupRollupOptionCompat(config.worker) config.optimizeDeps ??= {} setupRollupOptionCompat(config.optimizeDeps) - config.ssr ??= {} - config.ssr.optimizeDeps ??= {} - setupRollupOptionCompat(config.ssr.optimizeDeps) + if (config.ssr) { + config.ssr.optimizeDeps ??= {} + setupRollupOptionCompat(config.ssr.optimizeDeps) + } let configFileDependencies: string[] = [] let mode = inlineConfig.mode || defaultMode