Solvedangular cli Angular-cli 6 and base-href no longer supported?


Angular CLI: 6.0.0-rc.5
Node: 9.11.1
OS: win32 x64
Angular: 6.0.0-rc.5
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
@angular-devkit/architect         0.5.7
@angular-devkit/build-angular     0.5.7
@angular-devkit/build-optimizer   0.5.7
@angular-devkit/core              0.5.7
@angular-devkit/schematics        0.5.7
@ngtools/json-schema              1.1.0
@ngtools/webpack                  6.0.0-rc.5
@schematics/angular               0.5.7
@schematics/update                0.5.7
rxjs                              6.0.0-uncanny-rc.7
typescript                        2.7.2
webpack                           4.5.0

Repro steps

  • change index.html e.g. to base href="/v2"
  • ng serve -bh /v2/ or ng serve --base-href /v2/
  • in angular.json: "styles": ["node_modules/[at]fortawesome/fontawesome-free-webfonts/scss/fontawesome.scss",....

Observed behavior

option -bh or --base-href is no longer supported
without this option e.g. fonts will not be loaded correctly if a link including the base-href is loaded in the browser:
GET http://localhost:4200/v2/fa-solid-900.woff net::ERR_ABORTED
if i type just "http://localhost:4200" without any base-href it will redirect to /v2 but the ressources will be loaded.

Desired behavior

What is the alternative implementation in angular6?

20 Answers

✔️Accepted Answer

hi thanks for you hint. the servepath doesn't helped here but i found now a way to fix the problem by adding this to angular.json:

      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "baseHref" : "/v2/",
            "deployUrl": "/v2/",

i had to add baseHref and deployUrl instead of just base-href like in angular5

More Issues: