From 182d75d03f0ba34d6cd3440b50e9ea83f1acfcb7 Mon Sep 17 00:00:00 2001 From: Alan Agius <17563226+alan-agius4@users.noreply.github.com> Date: Fri, 30 Jan 2026 14:12:09 +0000 Subject: [PATCH 1/2] fix(@schematics/angular): warn when production configuration is missing for service worker When adding service worker support to a project, the schematic attempts to add the `serviceWorker` option to the `production` build configuration. If the `production` configuration is missing, the schematic would previously do nothing and not inform the user. This change adds a warning message to the console when the `production` configuration is not found, making it clear to the user why the `serviceWorker` option was not added. Fixes #32399 --- packages/schematics/angular/service-worker/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/schematics/angular/service-worker/index.ts b/packages/schematics/angular/service-worker/index.ts index 4ef2c9839def..98560f36d684 100644 --- a/packages/schematics/angular/service-worker/index.ts +++ b/packages/schematics/angular/service-worker/index.ts @@ -106,7 +106,7 @@ function getTsSourceFile(host: Tree, path: string): ts.SourceFile { } const serviceWorkerSchematic: RuleFactory = createProjectSchematic( - async (options, { project, workspace, tree }) => { + async (options, { project, workspace, tree, logger }) => { if (project.extensions.projectType !== 'application') { throw new SchematicsException(`Service worker requires a project type of "application".`); } @@ -126,6 +126,11 @@ const serviceWorkerSchematic: RuleFactory = createProjectS const productionConf = buildTarget.configurations?.production; if (productionConf) { productionConf.serviceWorker = ngswConfigPath; + } else { + logger.warn( + 'No "production" configuration found for build target. ' + + `The "serviceWorker" option with a value of "${ngswConfigPath}" will need to be set manually.`, + ); } } else { buildOptions.serviceWorker = true; From 1f90f1f55c4c59da5822bc0875b10181640b4790 Mon Sep 17 00:00:00 2001 From: Alan Agius <17563226+alan-agius4@users.noreply.github.com> Date: Fri, 30 Jan 2026 17:24:34 +0000 Subject: [PATCH 2/2] fixup! fix(@schematics/angular): warn when production configuration is missing for service worker --- packages/schematics/angular/service-worker/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/schematics/angular/service-worker/index.ts b/packages/schematics/angular/service-worker/index.ts index 98560f36d684..e80ab26c8096 100644 --- a/packages/schematics/angular/service-worker/index.ts +++ b/packages/schematics/angular/service-worker/index.ts @@ -106,7 +106,7 @@ function getTsSourceFile(host: Tree, path: string): ts.SourceFile { } const serviceWorkerSchematic: RuleFactory = createProjectSchematic( - async (options, { project, workspace, tree, logger }) => { + async (options, { project, workspace, tree, context: { logger } }) => { if (project.extensions.projectType !== 'application') { throw new SchematicsException(`Service worker requires a project type of "application".`); }