Skip to content

Commit

Permalink
fix(@angular/build): consistently set "default" baseHref
Browse files Browse the repository at this point in the history
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
  • Loading branch information
alan-agius4 committed Sep 19, 2024
1 parent ea4a125 commit b93708c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export async function executePostBundleSteps(
const prerenderedRoutes: string[] = [];

const {
baseHref = '/',
baseHref,
serviceWorker,
indexHtmlOptions,
optimizationOptions,
Expand Down
9 changes: 7 additions & 2 deletions packages/angular/build/src/builders/application/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,18 @@ export async function normalizeOptions(

// Initial options to keep
const {
/**
* Note: These default values should match those in schema.json.
* The reason these defaults are defined here is that, in certain internal builders,
* they are either not set or the options are provided.
*/
baseHref = '/',
inlineStyleLanguage = 'css',
allowedCommonJsDependencies,
aot,
baseHref,
crossOrigin,
externalDependencies,
extractLicenses,
inlineStyleLanguage = 'css',
outExtension,
serviceWorker,
poll,
Expand Down
5 changes: 3 additions & 2 deletions packages/angular/build/src/builders/application/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,8 @@
},
"baseHref": {
"type": "string",
"description": "Base url for the application being built."
"description": "Specifies the base URL for the application, used to resolve all relative URLs within the app.",
"default": "/"
},
"verbose": {
"type": "boolean",
Expand Down Expand Up @@ -531,7 +532,7 @@
}
},
"additionalProperties": false,
"required": ["outputPath", "index", "browser", "tsConfig"],
"required": ["outputPath", "index", "browser", "tsConfig", "inlineStyleLanguage", "baseHref"],
"definitions": {
"assetPattern": {
"oneOf": [
Expand Down

0 comments on commit b93708c

Please sign in to comment.