Skip to content

Commit

Permalink
feat(angular): add deployUrl to application builder (#22203)
Browse files Browse the repository at this point in the history
  • Loading branch information
leosvelperez committed Mar 8, 2024
1 parent 4983f52 commit 481c5aa
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 17 deletions.
4 changes: 4 additions & 0 deletions docs/generated/packages/angular/executors/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
"type": "string",
"description": "The full path for the TypeScript configuration file, relative to the current workspace."
},
"deployUrl": {
"type": "string",
"description": "Customize the base path for the URLs of resources in 'index.html' and component stylesheets. This option is only necessary for specific deployment scenarios, such as with Angular Elements or when utilizing different CDN locations. _Note: this is only supported in Angular versions >= 17.3.0_."
},
"scripts": {
"description": "Global scripts to be included in the build.",
"type": "array",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,7 @@
},
"deployUrl": {
"type": "string",
"description": "URL where files will be deployed.",
"x-deprecated": "Use \"baseHref\" option, \"APP_BASE_HREF\" DI token or a combination of both instead. For more information, see https://angular.io/guide/deployment#the-deploy-url."
"description": "Customize the base path for the URLs of resources in 'index.html' and component stylesheets. This option is only necessary for specific deployment scenarios, such as with Angular Elements or when utilizing different CDN locations."
},
"verbose": {
"type": "boolean",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,7 @@
},
"deployUrl": {
"type": "string",
"description": "URL where files will be deployed.",
"x-deprecated": "Use `baseHref` option, `APP_BASE_HREF` DI token or a combination of both instead. For more information, see https://angular.io/guide/deployment#the-deploy-url."
"description": "Customize the base path for the URLs of resources in 'index.html' and component stylesheets. This option is only necessary for specific deployment scenarios, such as with Angular Elements or when utilizing different CDN locations."
},
"verbose": {
"type": "boolean",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,7 @@
},
"deployUrl": {
"type": "string",
"description": "URL where files will be deployed.",
"x-deprecated": "Use \"baseHref\" browser builder option, \"APP_BASE_HREF\" DI token or a combination of both instead. For more information, see https://angular.io/guide/deployment#the-deploy-url."
"description": "Customize the base path for the URLs of resources in 'index.html' and component stylesheets. This option is only necessary for specific deployment scenarios, such as with Angular Elements or when utilizing different CDN locations."
},
"vendorChunk": {
"type": "boolean",
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/src/builders/webpack-browser/schema.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Schema } from '@angular-devkit/build-angular/src/builders/browser/schema';
import type { Schema } from '@angular-devkit/build-angular/src/builders/browser/schema';

export type BrowserBuilderSchema = Schema & {
customWebpackConfig?: {
Expand Down
3 changes: 1 addition & 2 deletions packages/angular/src/builders/webpack-browser/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,7 @@
},
"deployUrl": {
"type": "string",
"description": "URL where files will be deployed.",
"x-deprecated": "Use `baseHref` option, `APP_BASE_HREF` DI token or a combination of both instead. For more information, see https://angular.io/guide/deployment#the-deploy-url."
"description": "Customize the base path for the URLs of resources in 'index.html' and component stylesheets. This option is only necessary for specific deployment scenarios, such as with Angular Elements or when utilizing different CDN locations."
},
"verbose": {
"type": "boolean",
Expand Down
3 changes: 1 addition & 2 deletions packages/angular/src/builders/webpack-server/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@
},
"deployUrl": {
"type": "string",
"description": "URL where files will be deployed.",
"x-deprecated": "Use \"baseHref\" browser builder option, \"APP_BASE_HREF\" DI token or a combination of both instead. For more information, see https://angular.io/guide/deployment#the-deploy-url."
"description": "Customize the base path for the URLs of resources in 'index.html' and component stylesheets. This option is only necessary for specific deployment scenarios, such as with Angular Elements or when utilizing different CDN locations."
},
"vendorChunk": {
"type": "boolean",
Expand Down
4 changes: 4 additions & 0 deletions packages/angular/src/executors/application/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
"type": "string",
"description": "The full path for the TypeScript configuration file, relative to the current workspace."
},
"deployUrl": {
"type": "string",
"description": "Customize the base path for the URLs of resources in 'index.html' and component stylesheets. This option is only necessary for specific deployment scenarios, such as with Angular Elements or when utilizing different CDN locations. _Note: this is only supported in Angular versions >= 17.3.0_."
},
"scripts": {
"description": "Global scripts to be included in the build.",
"type": "array",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,12 @@ export function validateOptions(options: ApplicationExecutorOptions): void {
);
}
}

if (lt(angularVersion, '17.3.0-rc.0')) {
if (options.deployUrl) {
throw new Error(
`The "deployUrl" option requires Angular version 17.3.0 or greater. You are currently using version ${angularVersion}.`
);
}
}
}
3 changes: 1 addition & 2 deletions packages/angular/src/executors/browser-esbuild/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,7 @@
},
"deployUrl": {
"type": "string",
"description": "URL where files will be deployed.",
"x-deprecated": "Use \"baseHref\" option, \"APP_BASE_HREF\" DI token or a combination of both instead. For more information, see https://angular.io/guide/deployment#the-deploy-url."
"description": "Customize the base path for the URLs of resources in 'index.html' and component stylesheets. This option is only necessary for specific deployment scenarios, such as with Angular Elements or when utilizing different CDN locations."
},
"verbose": {
"type": "boolean",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ async function convertProjectTargets(
}

const { buildTargetName, serverTargetName } = getTargetsToConvert(
project.targets
project.targets,
angularVersion
);
if (!buildTargetName) {
warnIfProvided(
Expand Down Expand Up @@ -181,7 +182,9 @@ async function convertProjectTargets(
}

// Delete removed options
delete options['deployUrl'];
if (lt(angularVersion, '17.3.0-rc.0')) {
delete options['deployUrl'];
}
delete options['vendorChunk'];
delete options['commonChunk'];
delete options['resourcesOutputPath'];
Expand Down Expand Up @@ -266,7 +269,10 @@ async function convertProjectTargets(
return true;
}

function getTargetsToConvert(targets: Record<string, TargetConfiguration>): {
function getTargetsToConvert(
targets: Record<string, TargetConfiguration>,
angularVersion: string
): {
buildTargetName?: string;
serverTargetName?: string;
} {
Expand All @@ -286,7 +292,7 @@ function getTargetsToConvert(targets: Record<string, TargetConfiguration>): {
// build target
if (executorsToConvert.has(targets[target].executor)) {
for (const [, options] of allTargetOptions(targets[target])) {
if (options.deployUrl) {
if (lt(angularVersion, '17.3.0-rc.0') && options.deployUrl) {
logger.warn(
`The project is using the "deployUrl" option which is not available in the application builder. Skipping conversion.`
);
Expand Down

0 comments on commit 481c5aa

Please sign in to comment.