Skip to content

Commit 713f95d

Browse files
clydinKeen Yee Liau
authored andcommitted
fix(@angular-devkit/build-angular): localize service worker base href
1 parent cae943d commit 713f95d

File tree

1 file changed

+12
-2
lines changed
  • packages/angular_devkit/build_angular/src/browser

1 file changed

+12
-2
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -703,14 +703,24 @@ export function buildWebpackBrowser(
703703
}
704704

705705
if (!options.watch && options.serviceWorker) {
706-
for (const outputPath of outputPaths.values()) {
706+
for (const [locale, outputPath] of outputPaths.entries()) {
707+
let localeBaseHref;
708+
if (i18n.locales[locale] && i18n.locales[locale].baseHref !== '') {
709+
localeBaseHref = path.posix.join(
710+
options.baseHref || '',
711+
i18n.locales[locale].baseHref === undefined
712+
? `/${locale}/`
713+
: i18n.locales[locale].baseHref,
714+
);
715+
}
716+
707717
try {
708718
await augmentAppWithServiceWorker(
709719
host,
710720
root,
711721
normalize(projectRoot),
712722
normalize(outputPath),
713-
options.baseHref || '/',
723+
localeBaseHref || options.baseHref || '/',
714724
options.ngswConfigPath,
715725
);
716726
} catch (err) {

0 commit comments

Comments
 (0)