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 e3c97805bd9a..8521b9af6674 100644 --- a/packages/angular/build/src/builders/dev-server/vite-server.ts +++ b/packages/angular/build/src/builders/dev-server/vite-server.ts @@ -422,6 +422,7 @@ export async function* serveWithVite( componentStyles, templateUpdates, browserOptions.loader as EsbuildLoaderOption | undefined, + browserOptions.define, extensions?.middleware, transformers?.indexHtml, thirdPartySourcemaps, @@ -653,6 +654,7 @@ export async function setupServer( componentStyles: Map, templateUpdates: Map, prebundleLoaderExtensions: EsbuildLoaderOption | undefined, + define: ApplicationBuilderInternalOptions['define'], extensionMiddleware?: Connect.NextHandleFunction[], indexHtmlTransformer?: (content: string) => Promise, thirdPartySourcemaps = false, @@ -765,6 +767,7 @@ export async function setupServer( target, loader: prebundleLoaderExtensions, thirdPartySourcemaps, + define, }), }, plugins: [ @@ -802,6 +805,7 @@ export async function setupServer( zoneless, loader: prebundleLoaderExtensions, thirdPartySourcemaps, + define, }), }; diff --git a/packages/angular/build/src/tools/vite/utils.ts b/packages/angular/build/src/tools/vite/utils.ts index 83085d910f60..fc0d82c2ce62 100644 --- a/packages/angular/build/src/tools/vite/utils.ts +++ b/packages/angular/build/src/tools/vite/utils.ts @@ -57,6 +57,7 @@ export function getDepOptimizationConfig({ ssr, loader, thirdPartySourcemaps, + define = {}, }: { disabled: boolean; exclude: string[]; @@ -67,6 +68,7 @@ export function getDepOptimizationConfig({ zoneless: boolean; loader?: EsbuildLoaderOption; thirdPartySourcemaps: boolean; + define: Record | undefined; }): DepOptimizationConfig { const plugins: ViteEsBuildPlugin[] = [ { @@ -99,6 +101,7 @@ export function getDepOptimizationConfig({ plugins, loader, define: { + ...define, 'ngServerMode': `${ssr}`, }, resolveExtensions: ['.mjs', '.js', '.cjs'],