Skip to content

Commit e2cf25d

Browse files
authored
fix(ssr-build): Generate document in ssr build too! (#9310)
1 parent 984c9e0 commit e2cf25d

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

packages/vite/src/buildFeServer.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import path from 'path'
44
import type { PluginBuild } from 'esbuild'
55
import { build as esbuildBuild } from 'esbuild'
66
import type { Manifest as ViteBuildManifest } from 'vite'
7+
import { build as viteBuild } from 'vite'
78

89
import {
910
getRouteHookBabelPlugins,
@@ -65,18 +66,18 @@ export const buildFeServer = async ({ verbose, webDir }: BuildOptions = {}) => {
6566
// Step 1A: Generate the client bundle
6667
await buildWeb({ verbose })
6768

68-
// TODO (STREAMING) When Streaming is released Vite will be the only bundler,
69-
// so we can switch to a regular import
70-
// @NOTE: Using dynamic import, because vite is still opt-in
71-
const { build: viteBuild } = await import('vite')
72-
7369
// Step 1B: Generate the server output
7470
await viteBuild({
7571
configFile: viteConfigPath,
7672
build: {
77-
// Because we configure the root to be web/src, we need to go up one level
7873
outDir: rwPaths.web.distServer,
79-
ssr: rwPaths.web.entryServer,
74+
ssr: true, // use boolean, and supply the inputs in rollup options (see Documentation)
75+
rollupOptions: {
76+
input: {
77+
'entry.server': rwPaths.web.entryServer,
78+
Document: rwPaths.web.document, // We need the document for React's fallback
79+
},
80+
},
8081
},
8182
envFile: false,
8283
logLevel: verbose ? 'info' : 'warn',

0 commit comments

Comments
 (0)