Skip to content

Commit 7a627b4

Browse files
Broccohansl
authored andcommitted
fix(@angular-devkit/build-angular): Allow for config of ngsw-config.json path.
fixes angular/angular-cli#10357
1 parent c33cf0c commit 7a627b4

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

packages/angular_devkit/build_angular/src/angular-cli-files/utilities/service-worker/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export function augmentAppWithServiceWorker(
9494
appRoot: Path,
9595
outputPath: Path,
9696
baseHref: string,
97+
ngswConfigPath?: string,
9798
): Promise<void> {
9899
// Path to the worker script itself.
99100
const distPath = normalize(outputPath);
@@ -105,7 +106,7 @@ export function augmentAppWithServiceWorker(
105106
'@angular/service-worker/config',
106107
);
107108
const safetyPath = join(dirname(workerPath), 'safety-worker.js');
108-
const configPath = join(appRoot, 'ngsw-config.json');
109+
const configPath = ngswConfigPath as Path || join(appRoot, 'ngsw-config.json');
109110

110111
return host.exists(configPath).pipe(
111112
switchMap(exists => {

packages/angular_devkit/build_angular/src/browser/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ export class BrowserBuilder implements Builder<BrowserBuilderSchema> {
111111
projectRoot,
112112
resolve(root, normalize(options.outputPath)),
113113
options.baseHref || '/',
114+
options.ngswConfigPath,
114115
).then(
115116
() => {
116117
obs.next({ success: !stats.hasErrors() });

packages/angular_devkit/build_angular/src/browser/schema.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ export interface BrowserBuilderSchema {
181181
*/
182182
serviceWorker: boolean;
183183

184+
/**
185+
* Path to ngsw-config.json.
186+
*/
187+
ngswConfigPath?: string;
188+
184189
/**
185190
* Flag to prevent building an app shell.
186191
*/

packages/angular_devkit/build_angular/src/browser/schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@
194194
"description": "Generates a service worker config for production builds.",
195195
"default": false
196196
},
197+
"ngswConfigPath": {
198+
"type": "string",
199+
"description": "Path to ngsw-config.json."
200+
},
197201
"skipAppShell": {
198202
"type": "boolean",
199203
"description": "Flag to prevent building an app shell.",

0 commit comments

Comments
 (0)