angulardeploymentassetssubdirectory

Angular 2: assets not loaded when deployed in subdirectory


I'm trying to deploy my Angular 2 app in a sub directory: I searched SO and Google, and found I've to build it with the following command:

ng build -prod --base-href /angular-test --deploy-url /angular-test

but it's still not loading the assets.

Under networks in inspect, call to assets are going with:

/assets/i18n/en.json

whereas it should be

/angular-test/assets/i18n/en.json

Do I need to do something else?


Solution

  • Most of the examples I've seen are of this format:

    ng build --base-href /myUrl/
    

    So I would think you would need this:

    ng build --prod --base-href /angular-test/
    

    ( With a trailing slash )