Skip to content

Commit 942f80c

Browse files
author
Angular Builds
committed
4e6570520 fix(@angular-devkit/build-angular): baseHref with protocol and localize option
1 parent a4f3208 commit 942f80c

File tree

7 files changed

+38
-14
lines changed

7 files changed

+38
-14
lines changed

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
{
22
"name": "@angular-devkit/build-angular",
3-
"version": "0.901.0-next.0+7.764b977",
3+
"version": "0.901.0-next.0+8.4e65705",
44
"description": "Angular Webpack Build Facade",
55
"experimental": true,
66
"main": "src/index.js",
77
"typings": "src/index.d.ts",
88
"builders": "builders.json",
99
"dependencies": {
10-
"@angular-devkit/architect": "github:angular/angular-devkit-architect-builds#764b977de",
11-
"@angular-devkit/build-optimizer": "github:angular/angular-devkit-build-optimizer-builds#764b977de",
12-
"@angular-devkit/build-webpack": "github:angular/angular-devkit-build-webpack-builds#764b977de",
13-
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#764b977de",
10+
"@angular-devkit/architect": "github:angular/angular-devkit-architect-builds#4e6570520",
11+
"@angular-devkit/build-optimizer": "github:angular/angular-devkit-build-optimizer-builds#4e6570520",
12+
"@angular-devkit/build-webpack": "github:angular/angular-devkit-build-webpack-builds#4e6570520",
13+
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#4e6570520",
1414
"@babel/core": "7.8.4",
1515
"@babel/preset-env": "7.8.4",
1616
"@babel/template": "7.8.3",
17-
"@ngtools/webpack": "github:angular/ngtools-webpack-builds#764b977de",
17+
"@ngtools/webpack": "github:angular/ngtools-webpack-builds#4e6570520",
1818
"ajv": "6.12.0",
1919
"autoprefixer": "9.7.4",
2020
"babel-loader": "8.0.6",

src/browser/index.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
136136
}).pipe(
137137
// tslint:disable-next-line: no-big-function
138138
operators_1.concatMap(async (buildEvent) => {
139+
var _a, _b;
139140
const { webpackStats: webpackRawStats, success, emittedFiles = [] } = buildEvent;
140141
if (!webpackRawStats) {
141142
throw new Error('Webpack stats build result is required.');
@@ -245,7 +246,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
245246
fs.unlinkSync(filename + '.map');
246247
}
247248
}
248-
catch (_a) { }
249+
catch (_c) { }
249250
}
250251
if (es5Polyfills) {
251252
fs.unlinkSync(filename);
@@ -467,9 +468,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
467468
for (const [locale, outputPath] of outputPaths.entries()) {
468469
let localeBaseHref;
469470
if (i18n.locales[locale] && i18n.locales[locale].baseHref !== '') {
470-
localeBaseHref = path.posix.join(options.baseHref || '', i18n.locales[locale].baseHref === undefined
471-
? `/${locale}/`
472-
: i18n.locales[locale].baseHref);
471+
localeBaseHref = utils_1.urlJoin(options.baseHref || '', (_a = i18n.locales[locale].baseHref, (_a !== null && _a !== void 0 ? _a : `/${locale}/`)));
473472
}
474473
try {
475474
await generateIndex(outputPath, options, root, files, noModuleFiles, moduleFiles, transforms.indexHtml,
@@ -485,9 +484,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
485484
for (const [locale, outputPath] of outputPaths.entries()) {
486485
let localeBaseHref;
487486
if (i18n.locales[locale] && i18n.locales[locale].baseHref !== '') {
488-
localeBaseHref = path.posix.join(options.baseHref || '', i18n.locales[locale].baseHref === undefined
489-
? `/${locale}/`
490-
: i18n.locales[locale].baseHref);
487+
localeBaseHref = utils_1.urlJoin(options.baseHref || '', (_b = i18n.locales[locale].baseHref, (_b !== null && _b !== void 0 ? _b : `/${locale}/`)));
491488
}
492489
try {
493490
await service_worker_1.augmentAppWithServiceWorker(host, root, core_1.normalize(projectRoot), core_1.normalize(outputPath), localeBaseHref || options.baseHref || '/', options.ngswConfigPath);

src/utils/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ export * from './normalize-asset-patterns';
1414
export * from './normalize-source-maps';
1515
export * from './normalize-optimization';
1616
export * from './normalize-builder-schema';
17+
export * from './url';

src/utils/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ __export(require("./normalize-asset-patterns"));
1919
__export(require("./normalize-source-maps"));
2020
__export(require("./normalize-optimization"));
2121
__export(require("./normalize-builder-schema"));
22+
__export(require("./url"));

src/utils/url.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
export declare function urlJoin(...parts: string[]): string;

src/utils/url.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"use strict";
2+
/**
3+
* @license
4+
* Copyright Google Inc. All Rights Reserved.
5+
*
6+
* Use of this source code is governed by an MIT-style license that can be
7+
* found in the LICENSE file at https://angular.io/license
8+
*/
9+
Object.defineProperty(exports, "__esModule", { value: true });
10+
function urlJoin(...parts) {
11+
const [p, ...rest] = parts;
12+
// Remove trailing slash from first part
13+
// Join all parts with `/`
14+
// Dedupe double slashes from path names
15+
return p.replace(/\/$/, '') + ('/' + rest.join('/')).replace(/\/\/+/g, '/');
16+
}
17+
exports.urlJoin = urlJoin;

uniqueId

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Mon Feb 24 2020 21:20:11 GMT+0000 (Coordinated Universal Time)
1+
Mon Feb 24 2020 21:27:48 GMT+0000 (Coordinated Universal Time)

0 commit comments

Comments
 (0)