angular/angular-cli · warning
No "production" configuration found for build target. The "s
Error message
No "production" configuration found for build target. The "serviceWorker" option with a value of "${ngswConfigPath}" will need to be set manually. What it means
The service-worker schematic adds @angular/service-worker and wires ngsw-config.json into the build target. If the target uses a modern application builder but has no 'production' configuration block, the schematic cannot set serviceWorker automatically and warns that you must add it yourself.
Source
Thrown at packages/schematics/angular/service-worker/index.ts:130
}
const buildTarget = project.targets.get('build');
if (!buildTarget) {
throw targetBuildNotFoundError();
}
const buildOptions = buildTarget.options as Record<string, string | boolean>;
const browserEntryPoint = await getMainFilePath(tree, options.project);
const ngswConfigPath = join(project.root, 'ngsw-config.json');
if (
buildTarget.builder === Builders.Application ||
buildTarget.builder === Builders.BuildApplication
) {
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;
buildOptions.ngswConfigPath = ngswConfigPath;
}
await writeWorkspace(tree, workspace);
return chain([
addDependencies(),
mergeWith(
apply(url('./files'), [
applyTemplates({
...options,
relativePathToWorkspaceRoot: relativePathToWorkspaceRoot(project.root),View on GitHub (pinned to bb72145f9a)
Solutions
- Add a "production" configuration to the build target in angular.json
- Inside it set "serviceWorker": "ngsw-config.json" (path to your ngsw-config.json)
- Verify the build target's builder is the application builder and re-run ng add / the build to confirm ngsw is wired
Example fix
// before (angular.json build target)
"configurations": { "development": { ... } }
// after
"configurations": {
"production": { "serviceWorker": "ngsw-config.json", "outputHashing": "all" }
} Defensive patterns
Strategy: validation
Validate before calling
// before running the service-worker schematic, ensure a production configuration exists
const build = angularJson.projects[proj].architect?.build;
const usesApplicationBuilder = ['@angular-devkit/build-angular:application','@angular/build:application'].includes(build?.builder);
if (usesApplicationBuilder && !build.configurations?.production) {
console.warn('Add a production configuration before adding a service worker');
} Type guard
function hasProductionConf(buildTarget) {
return typeof buildTarget?.builder === 'string' &&
buildTarget.configurations != null &&
typeof buildTarget.configurations.production === 'object' &&
buildTarget.configurations.production !== null;
} Prevention
- Never strip the production configuration from angular.json build targets
- After builder migrations, re-add required production options (outputHashing, serviceWorker, budgets)
- Run builds with --configuration production regularly to surface missing production config early
When it happens
Trigger: Running the service-worker schematic (ng add @angular/pwa or the service-worker schematic) on a project whose build target builder is BuildApplication/BuildDevServer but buildTarget.configurations.production is undefined.
Common situations: Projects created or trimmed without a production configuration in angular.json, or projects migrated to the application builder with custom/simplified configurations.
Related errors
- Project target "build" not found.
- Option "project" is required.
- Project is not defined in this workspace.
- PWA requires a project type of "application".
- Targets are not defined for this project.
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/e696d81549fad1d8.
Report an issue: GitHub.