diff --git a/docs/config/ssr-options.md b/docs/config/ssr-options.md index 356c4e66eabad6..d5f96bdb415fca 100644 --- a/docs/config/ssr-options.md +++ b/docs/config/ssr-options.md @@ -20,3 +20,19 @@ Prevent listed dependencies from being externalized for SSR. If `true`, no depen - **Default:** `node` Build target for the SSR server. + +## ssr.resolve.conditions + +- **Type:** `string[]` +- **Related:** [Resolve Conditions](./shared-options.md#resolve-conditions) + +Defaults to the the root [`resolve.conditions`](./shared-options.md#resolve-conditions). + +These conditions are used in the plugin pipeline, and only affect non-externalized dependencies during the SSR build. Use `ssr.resolve.externalConditions` to affect externalized imports. + +## ssr.resolve.externalConditions + +- **Type:** `string[]` +- **Default:** `[]` + +Conditions that are used during ssr import (including `ssrLoadModule`) of externalized dependencies. diff --git a/docs/guide/ssr.md b/docs/guide/ssr.md index d208a9bcd87bb0..d7c4ecd4108653 100644 --- a/docs/guide/ssr.md +++ b/docs/guide/ssr.md @@ -259,6 +259,10 @@ In some cases like `webworker` runtimes, you might want to bundle your SSR build - Treat all dependencies as `noExternal` - Throw an error if any Node.js built-ins are imported +## SSR Resolve conditions + +By default package entry resolution will use the conditions set in [Resolve Conditions](../config/shared-options.md#resolve-conditions) for the SSR build. You can use [`ssr.resolve.conditions`](../config/ssr-options.md#ssr-resolve-conditions) and [`ssr.resolve.externalConditions`](../config/ssr-options.md#ssr-resolve-externalconditions) to customize this behavior. + ## Vite CLI The CLI commands `$ vite dev` and `$ vite preview` can also be used for SSR apps. You can add your SSR middlewares to the development server with [`configureServer`](/guide/api-plugin#configureserver) and to the preview server with [`configurePreviewServer`](/guide/api-plugin#configurepreviewserver).