-
Notifications
You must be signed in to change notification settings - Fork 994
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SSR: Extract buildForStreamingServer function (#10099)
- Loading branch information
Showing
2 changed files
with
45 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { build as viteBuild } from 'vite' | ||
|
||
import { getPaths } from '@redwoodjs/project-config' | ||
|
||
export async function buildForStreamingServer({ | ||
verbose = false, | ||
}: { | ||
verbose?: boolean | ||
}) { | ||
console.log('Starting streaming server build...\n') | ||
const rwPaths = getPaths() | ||
|
||
if (!rwPaths.web.viteConfig) { | ||
throw new Error('Vite config not found') | ||
} | ||
|
||
await viteBuild({ | ||
configFile: rwPaths.web.viteConfig, | ||
build: { | ||
outDir: rwPaths.web.distServer, | ||
ssr: true, | ||
emptyOutDir: true, | ||
}, | ||
legacy: { | ||
// @MARK The Streaming SSR build produces CJS output. RSC is ESM | ||
// TODO: Remove this config once we can build ESM output for streaming | ||
// too | ||
buildSsrCjsExternalHeuristics: true, | ||
}, | ||
envFile: false, | ||
logLevel: verbose ? 'info' : 'warn', | ||
}) | ||
} |