Skip to content

Commit

Permalink
fix(ssr-build): Generate document in ssr build too! (#9310)
Browse files Browse the repository at this point in the history
  • Loading branch information
dac09 committed Oct 17, 2023
1 parent 984c9e0 commit e2cf25d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions packages/vite/src/buildFeServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import path from 'path'
import type { PluginBuild } from 'esbuild'
import { build as esbuildBuild } from 'esbuild'
import type { Manifest as ViteBuildManifest } from 'vite'
import { build as viteBuild } from 'vite'

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

// TODO (STREAMING) When Streaming is released Vite will be the only bundler,
// so we can switch to a regular import
// @NOTE: Using dynamic import, because vite is still opt-in
const { build: viteBuild } = await import('vite')

// Step 1B: Generate the server output
await viteBuild({
configFile: viteConfigPath,
build: {
// Because we configure the root to be web/src, we need to go up one level
outDir: rwPaths.web.distServer,
ssr: rwPaths.web.entryServer,
ssr: true, // use boolean, and supply the inputs in rollup options (see Documentation)
rollupOptions: {
input: {
'entry.server': rwPaths.web.entryServer,
Document: rwPaths.web.document, // We need the document for React's fallback
},
},
},
envFile: false,
logLevel: verbose ? 'info' : 'warn',
Expand Down

0 comments on commit e2cf25d

Please sign in to comment.