As long you are running your Angular application at a root URL (e.g. www.myangularapp.com) you don’t need to worry that much about either the ‘--deploy-url’ and ‘--base-href’ parameters.
But once you want to serve your Angular application from a server sub folder(e.g. www.mywebsite.com/angularapp ) these parameters become important.
--base-href
If you deploy your Angular app to a subfolder, the ‘--base-href’ is important to generate the correct routes. This parameter will update the <base href> tag inside the index.html.
For example, if the index.html
is on the server at /angularapp/index.html
, the base href should be set to <base href="/angularapp/">
.
More information: https://angular.io/guide/deployment
--deploy-url
A second parameter that is important is ‘--deploy-url’. This parameter will update the generated url’s for our assets(scripts, css) inside the index.html.
To make your assets available at /angularapp/, the deploy url should be set to /angularapp/.
A complete example would look like this:
ng build --prod --base-href /angularapp/ --deploy-url /angularapp/