Skip to content

refactor(@angular/cli): provide default serve target for applications #28011

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor(@angular/build): allow development server buildTarget opti…
…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 Mar 19, 2025
commit aa848cf1c7fc4cb500391ece03615ab445d0e960
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 @@ -109,7 +109,7 @@ export enum BuildOutputFileType {
// @public
export type DevServerBuilderOptions = {
allowedHosts?: AllowedHosts;
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 @@ -127,5 +127,5 @@
}
},
"additionalProperties": false,
"required": ["buildTarget"]
"required": []
}