Skip to content

Commit 84e4155

Browse files
committed
fix(@angular/build): consistently set "default" baseHref
Previously, the default value for baseHref (set to `/`) was defined in multiple places, leading to inconsistency. A recent commit inadvertently removed one of these defaults see: https://github.com/angular/angular-cli/pull/28283/files#diff-803b0bd9e1fd57eefba877e946b85b13517170ad5fadb906a11308bc4b3b9fdaL148 This change consolidates the default logic by removing redundant definitions and moving the default baseHref configuration to schema.json for consistency. Closes angular#28442
1 parent ea4a125 commit 84e4155

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

packages/angular/build/src/builders/application/execute-post-bundle.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export async function executePostBundleSteps(
5252
const prerenderedRoutes: string[] = [];
5353

5454
const {
55-
baseHref = '/',
55+
baseHref,
5656
serviceWorker,
5757
indexHtmlOptions,
5858
optimizationOptions,

packages/angular/build/src/builders/application/options.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,18 @@ export async function normalizeOptions(
305305

306306
// Initial options to keep
307307
const {
308+
/**
309+
* Note: These default values should match those in schema.json.
310+
* The reason these defaults are defined here is that, in certain internal builders,
311+
* they are either not set or the options are provided.
312+
*/
313+
baseHref = '/',
314+
inlineStyleLanguage = 'css',
308315
allowedCommonJsDependencies,
309316
aot,
310-
baseHref,
311317
crossOrigin,
312318
externalDependencies,
313319
extractLicenses,
314-
inlineStyleLanguage = 'css',
315320
outExtension,
316321
serviceWorker,
317322
poll,

packages/angular/build/src/builders/application/schema.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,8 @@
315315
},
316316
"baseHref": {
317317
"type": "string",
318-
"description": "Base url for the application being built."
318+
"description": "Specifies the base URL for the application, used to resolve all relative URLs within the app.",
319+
"default": "/"
319320
},
320321
"verbose": {
321322
"type": "boolean",

0 commit comments

Comments
 (0)