Skip to content

Commit

Permalink
docs: explain what a deploy url is and how it differs from a base href (
Browse files Browse the repository at this point in the history
#42363)

fixes #34931

PR Close #42363
  • Loading branch information
wagnermaciel authored and umairhm committed May 28, 2021
1 parent 2f07267 commit ea4b227
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions aio/content/guide/deployment.md
Expand Up @@ -451,6 +451,22 @@ the subfolder is `my/app/` and you should add `<base href="/my/app/">` to the se
When the `base` tag is mis-configured, the application fails to load and the browser console displays `404 - Not Found` errors
for the missing files. Look at where it _tried_ to find those files and adjust the base tag appropriately.

{@a deploy-url}

## The `deploy` url

A command line option used to specify the base path for resolving relative URLs for assets such as images, scripts, and style sheets at _compile_ time. For example: `ng build --deploy-url /my/assets`.

The effects of defining a `deploy url` and `base href` can overlap.
* Both can be used for initial scripts, stylesheets, lazy scripts, and css resources.

However, defining a `base href` has a few unique effects.
* Defining a `base href` can be used for locating relative template (HTML) assets, and relative fetch/XMLHttpRequests.

The `base href` can also be used to define the Angular router's default base (see [APP_BASE_HREF](https://angular.io/api/common/APP_BASE_HREF)). Users with more complicated setups may need to manually configure the `APP_BASE_HREF` token within the application. (e.g., application routing base is / but assets/scripts/etc. are at /assets/).

Unlike the `base href` which can be defined in a single place, the `deploy url` needs to be hard-coded into an application at build time. This means specifying a `deploy url` will decrease build speed, but this is the unfortunate cost of using an option that embeds itself throughout an application. That is why a `base href` is generally the better option.

{@a differential-loading}

## Differential Loading
Expand Down

0 comments on commit ea4b227

Please sign in to comment.