angular-cli: Angular-cli 6 and base-href no longer supported?

Versions

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?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 2
  • Comments: 19 (2 by maintainers)

Commits related to this issue

Most upvoted comments

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

I’m sorry, but we can’t reproduce the problem following the instructions you provided. Remember that we have a large number of issues to resolve, and have only a limited amount of time to reproduce your issue. Short, explicit instructions make it much more likely we’ll be able to reproduce the problem so we can fix it.

If the problem persists, please open a new issue following our submission guidelines.

A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.

@alan-agius4 The issue is obviously not understood properly. Please provide clear guidance on how to utilize configuration options and/or cli arguments for base/baseHref. If this is no longer supported, the answer to this issue would be very simple. There is no need to reproduce anything.

Thanks!

I encountered this issue while using @angular-builders/dev-server:generic instead of the default builder for ng serve. However, after reading the docs for this package, I saw that it has a peer dependency of "@angular-devkit/build-angular": ">=0.12.1", which was not up to date in package.json from when I initiated this project with ng new project. I changed the version, npm install, success! I did not have to add the baseHref option in angular.json to get it to compile after making this change.

More background reading here too. https://medium.com/@GrandSchtroumpf/angular-cli-and-web3-e5cb90885741

Can you respond to questions at least…

Someone can tell the real solution ?

  1. APP_BASE_HREF with some “environment” variable

  2. ng build --prod --base-href /my/app/

  3. angular.json with baseHref and deployUrl

Wich is it ?

@DaveXCS it’s not work for me this is angular.json 2018-09-07 10 26 23

and this is bundle index.html file 2018-09-07 10 26 33

Note that you have to escape the path if you want to set this options programatically:

 ng config projects.demo.architect.build.options.baseHref "'/base/'"

Otherwise the /base/ slug will be interpreted as path.