diff --git a/packages/angular/build/src/builders/dev-server/vite-server.ts b/packages/angular/build/src/builders/dev-server/vite-server.ts index 659d51bb2165..33a000a91f9b 100644 --- a/packages/angular/build/src/builders/dev-server/vite-server.ts +++ b/packages/angular/build/src/builders/dev-server/vite-server.ts @@ -651,6 +651,8 @@ export async function setupServer( host: serverOptions.host, open: serverOptions.open, headers: serverOptions.headers, + // Disable the websocket if live reload is disabled (false/undefined are the only valid values) + ws: serverOptions.liveReload === false && serverOptions.hmr === false ? false : undefined, proxy, cors: { // Allow preflight requests to be proxied. @@ -711,6 +713,7 @@ export async function setupServer( virtualProjectRoot, outputFiles, external: externalMetadata.explicitBrowser, + skipViteClient: serverOptions.liveReload === false && serverOptions.hmr === false, }), ], // Browser only optimizeDeps. (This does not run for SSR dependencies). diff --git a/packages/angular/build/src/tools/vite/plugins/angular-memory-plugin.ts b/packages/angular/build/src/tools/vite/plugins/angular-memory-plugin.ts index 1f5012b028f3..0af30710f2a9 100644 --- a/packages/angular/build/src/tools/vite/plugins/angular-memory-plugin.ts +++ b/packages/angular/build/src/tools/vite/plugins/angular-memory-plugin.ts @@ -17,6 +17,7 @@ interface AngularMemoryPluginOptions { virtualProjectRoot: string; outputFiles: AngularMemoryOutputFiles; external?: string[]; + skipViteClient?: boolean; } export async function createAngularMemoryPlugin( @@ -55,9 +56,11 @@ export async function createAngularMemoryPlugin( const relativeFile = '/' + normalizePath(relative(virtualProjectRoot, file)); const codeContents = outputFiles.get(relativeFile)?.contents; if (codeContents === undefined) { - return relativeFile.endsWith('/node_modules/vite/dist/client/client.mjs') - ? loadViteClientCode(file) - : undefined; + if (relativeFile.endsWith('/node_modules/vite/dist/client/client.mjs')) { + return options.skipViteClient ? '' : loadViteClientCode(file); + } + + return undefined; } const code = Buffer.from(codeContents).toString('utf-8');