Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: emit assets from SSR build #11430

Merged
merged 7 commits into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/vite/src/node/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ export interface BuildOptions {
* directives in production.
*/
ssrManifest?: boolean | string
/**
* Emit assets during SSR.
* @experimental
* @default false
*/
ssrEmitAssets?: boolean
/**
* Set to false to disable reporting compressed chunk sizes.
* Can slightly improve build speed.
Expand Down Expand Up @@ -324,6 +330,7 @@ export function resolveBuildOptions(
lib: false,
ssr: false,
ssrManifest: false,
ssrEmitAssets: false,
reportCompressedSize: true,
chunkSizeWarningLimit: 500,
watch: null,
Expand Down
6 changes: 5 additions & 1 deletion packages/vite/src/node/plugins/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,11 @@ export function assetPlugin(config: ResolvedConfig): Plugin {

generateBundle(_, bundle) {
// do not emit assets for SSR build
if (config.command === 'build' && config.build.ssr) {
if (
config.command === 'build' &&
config.build.ssr &&
!config.build.ssrEmitAssets
) {
for (const file in bundle) {
if (
bundle[file].type === 'asset' &&
Expand Down