Skip to content

Commit 8bb6799

Browse files
clydinKeen Yee Liau
authored and
Keen Yee Liau
committed
fix(@angular-devkit/build-angular): localize service worker base href
1 parent 8d181b6 commit 8bb6799

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
@@ -729,14 +729,24 @@ export function buildWebpackBrowser(
729729
}
730730

731731
if (!options.watch && options.serviceWorker) {
732-
for (const outputPath of outputPaths.values()) {
732+
for (const [locale, outputPath] of outputPaths.entries()) {
733+
let localeBaseHref;
734+
if (i18n.locales[locale] && i18n.locales[locale].baseHref !== '') {
735+
localeBaseHref = path.posix.join(
736+
options.baseHref || '',
737+
i18n.locales[locale].baseHref === undefined
738+
? `/${locale}/`
739+
: i18n.locales[locale].baseHref,
740+
);
741+
}
742+
733743
try {
734744
await augmentAppWithServiceWorker(
735745
host,
736746
root,
737747
normalize(projectRoot),
738748
normalize(outputPath),
739-
options.baseHref || '/',
749+
localeBaseHref || options.baseHref || '/',
740750
options.ngswConfigPath,
741751
);
742752
} catch (err) {

0 commit comments

Comments
 (0)