Skip to content

Commit

Permalink
fix(@angular/build): skip vite SSR warmup file configuration when SSR…
Browse files Browse the repository at this point in the history
… is disabled

This change addresses recent updates in Vite that trigger pre-transform errors when SSR files (`/server.mjs`, `/main.server.mjs`) are missing. Skipping the configuration prevents unnecessary errors during the build process.
  • Loading branch information
alan-agius4 committed Jan 8, 2025
1 parent ebc3cc8 commit 48cae81
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/angular/build/src/builders/dev-server/vite-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,17 @@ export async function setupServer(
join(serverOptions.workspaceRoot, `.angular/vite-root`, serverOptions.buildTarget.project),
);

// Files used for SSR warmup.
let ssrFiles: string[] | undefined;
switch (ssrMode) {
case ServerSsrMode.InternalSsrMiddleware:
ssrFiles = ['./main.server.mjs'];
break;
case ServerSsrMode.ExternalSsrMiddleware:
ssrFiles = ['./main.server.mjs', './server.mjs'];
break;
}

const cacheDir = join(serverOptions.cacheOptions.path, serverOptions.buildTarget.project, 'vite');
const configuration: InlineConfig = {
configFile: false,
Expand Down Expand Up @@ -701,7 +712,7 @@ export async function setupServer(
},
server: {
warmup: {
ssrFiles: ['./main.server.mjs', './server.mjs'],
ssrFiles,
},
port: serverOptions.port,
strictPort: true,
Expand Down

0 comments on commit 48cae81

Please sign in to comment.