Skip to content

Commit

Permalink
refactor(@angular/build): allow development server buildTarget opti…
Browse files Browse the repository at this point in the history
…on to be optional

The development server (`dev-server`) within `@angular/build` no longer
requires a `buildTarget` option to be specified. If not present, the value
will default to the current project's 'build' target. The configuration used
for the build target will be the same as the development server configuration
if specified or, if not specified, it will default to `development`.
  • Loading branch information
clydin committed Jul 9, 2024
1 parent b55c545 commit 7701ee6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion goldens/public-api/angular/build/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export enum BuildOutputFileType {

// @public
export interface DevServerBuilderOptions {
buildTarget: string;
buildTarget?: string;
headers?: {
[key: string]: string;
};
Expand Down
6 changes: 4 additions & 2 deletions packages/angular/build/src/builders/dev-server/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ export async function normalizeOptions(

const cacheOptions = normalizeCacheOptions(projectMetadata, workspaceRoot);

// Target specifier defaults to the current project's build target using a development configuration
const buildTargetSpecifier = options.buildTarget ?? `::development`;
// Target specifier defaults to the current project's build target using the provided dev-server
// configuration if a configuration is present or the 'development' configuration if not.
const buildTargetSpecifier =
options.buildTarget ?? `::${context.target?.configuration || 'development'}`;
const buildTarget = targetFromTargetString(buildTargetSpecifier, projectName, 'build');

// Get the application builder options.
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/build/src/builders/dev-server/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,5 @@
}
},
"additionalProperties": false,
"required": ["buildTarget"]
"required": []
}

0 comments on commit 7701ee6

Please sign in to comment.