Angular-cli: ng build --prod error because ngsw-config.json not moved during migration

Created on 16 Apr 2018  路  9Comments  路  Source: angular/angular-cli

Versions

cli v6.0.0-rc.4

Repro steps

From an Angular 5 project generated with --service-worker:

  • update and migrate to v6
  • ng build --prod

Observed behavior

Error: Expected to find an ngsw-config.json configuration file in the /path/to/app folder.

Desired behavior

Migration from CLI 1.7 to 6.0 should move /src/ngsw-config.json to /ngsw-config.json if existing.

2 (required)

Most helpful comment

I resolved my issue on windows by changing the path created in angular.json during ng upgrade from
"ngswConfigPath": "/src/ngsw-config.json",
to
"ngswConfigPath": "src/ngsw-config.json",

Removing the leading /

All 9 comments

same problem here...

Actions: keep the file at the current path, but add argument option to the build and set the option properly if the file exists.

I resolved my issue on windows by changing the path created in angular.json during ng upgrade from
"ngswConfigPath": "/src/ngsw-config.json",
to
"ngswConfigPath": "src/ngsw-config.json",

Removing the leading /

but ngswConfigPath option isn't defined in the cli json schema... editor is reporting it as invalid...

Is the schema.json updated in https://github.com/Brocco/devkit/commit/cea4245e8c7539a6a1b90d70388aae60d3a92bdd released?

@royling just delete the whole line "ngswConfigPath": "/src/ngsw-config.json", from angular.json. It seems to still register the service worker OK. I got this from SO.

@markau Thanks, it also needs to move src/ngsw-config.json to the project root dir (same as angular.json). I guess that's how service worker works implicitly within the new CLI.

I was having the same problem when my config file configure like this:
"ngswConfigPath": "src/ngsw-config.json"
I was trying to build ng b --prod from src/app/shared instead of building from the root folder.
Building from the root folder fix the issue for me.

Well. My "ngsw-config.json" file is in the root directory and in my angular.json I set
"ngswConfigPath": "./ngsw-config.json" AND its working smoothly. So idea is to provide the path of ngsw-config.json file simple.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

IngvarKofoed picture IngvarKofoed  路  3Comments

NCC1701M picture NCC1701M  路  3Comments

rajjejosefsson picture rajjejosefsson  路  3Comments

sysmat picture sysmat  路  3Comments

jbeckton picture jbeckton  路  3Comments