Skip to content

Commit

Permalink
fix: emit assets from SSR build (#11430)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris authored Jan 26, 2023
1 parent f3a0c3b commit ffbdcdb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
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

0 comments on commit ffbdcdb

Please sign in to comment.