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) {