📜  angular build deploy url - Javascript (1)

📅  最后修改于: 2023-12-03 14:59:17.969000             🧑  作者: Mango

Angular CLI - ng build --deploy-url Command

When building an Angular application, you might need to deploy your application to a specific URL, which is where ng build --deploy-url command comes in handy.

The --deploy-url option specifies the base href URL for the application being built.

Usage

Build the application for production:

$ ng build --prod --deploy-url https://example.com/

This command will generate the production build of your Angular application with the base href URL set to https://example.com/.

Alternatively, you can set the --deploy-url option in the angular.json configuration file, as shown below:

{
  "projects": {
    "my-project": {
      "architect": {
        "build": {
          "options": {
            "deployUrl": "https://example.com/"
          }
        }
      }
    }
  }
}

Note: When deploying the Angular application, be sure to serve the application from the specified URL.

Conclusion

ng build --deploy-url is a very useful command when building Angular applications that need to be deployed to specific URLs. With this command, you can easily and quickly deploy your Angular application to the required URL.

Happy Coding! :rocket:

Markdown snippet
# Angular CLI - `ng build --deploy-url` Command

When building an Angular application, you might need to deploy your application to a specific URL, which is where `ng build --deploy-url` command comes in handy.

The `--deploy-url` option specifies the base href URL for the application being built. 

## Usage

Build the application for production:

```
$ ng build --prod --deploy-url https://example.com/
```

This command will generate the production build of your Angular application with the base href URL set to `https://example.com/`.

Alternatively, you can set the `--deploy-url` option in the `angular.json` configuration file, as shown below:

```
{
  "projects": {
    "my-project": {
      "architect": {
        "build": {
          "options": {
            "deployUrl": "https://example.com/"
          }
        }
      }
    }
  }
}
```

>Note: When deploying the Angular application, be sure to serve the application from the specified URL. 

## Conclusion

`ng build --deploy-url` is a very useful command when building Angular applications that need to be deployed to specific URLs. With this command, you can easily and quickly deploy your Angular application to the required URL. 

Happy Coding! :rocket: