From 8bb679924a0d5f2fa5db98259f8b83f8185578cf Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Wed, 4 Dec 2019 13:40:35 -0500 Subject: [PATCH] fix(@angular-devkit/build-angular): localize service worker base href --- .../build_angular/src/browser/index.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/angular_devkit/build_angular/src/browser/index.ts b/packages/angular_devkit/build_angular/src/browser/index.ts index e8b9433439e7..fe3f304ac003 100644 --- a/packages/angular_devkit/build_angular/src/browser/index.ts +++ b/packages/angular_devkit/build_angular/src/browser/index.ts @@ -729,14 +729,24 @@ export function buildWebpackBrowser( } if (!options.watch && options.serviceWorker) { - for (const outputPath of outputPaths.values()) { + for (const [locale, outputPath] of outputPaths.entries()) { + let localeBaseHref; + if (i18n.locales[locale] && i18n.locales[locale].baseHref !== '') { + localeBaseHref = path.posix.join( + options.baseHref || '', + i18n.locales[locale].baseHref === undefined + ? `/${locale}/` + : i18n.locales[locale].baseHref, + ); + } + try { await augmentAppWithServiceWorker( host, root, normalize(projectRoot), normalize(outputPath), - options.baseHref || '/', + localeBaseHref || options.baseHref || '/', options.ngswConfigPath, ); } catch (err) {