diff --git a/packages/schematics/angular/service-worker/index.ts b/packages/schematics/angular/service-worker/index.ts index 4ef2c9839def..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 }) => { + async (options, { project, workspace, tree, context: { 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;