Angular-cli: ng build --base-href or -bh generates incorrect base href in the index.html

Created on 29 Sep 2017  Â·  5Comments  Â·  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

- [X ] bug report -> please search issues before submitting
- [ ] feature request

Versions.

Output from: ng --version.

$ ng --version
    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / â–³ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
@angular/cli: 1.4.4
node: 8.1.2
os: win32 x64
@angular/animations: 4.4.4
@angular/common: 4.4.4
@angular/compiler: 4.4.4
@angular/core: 4.4.4
@angular/forms: 4.4.4
@angular/http: 4.4.4
@angular/platform-browser: 4.4.4
@angular/platform-browser-dynamic: 4.4.4
@angular/router: 4.4.4
@angular/cli: 1.4.4
@angular/compiler-cli: 4.4.4
@angular/language-service: 4.4.4
typescript: 2.3.4
$ npm -v
5.0.3
$ node -v
v8.1.2

OS: WIndows 10

Repro steps.

  1. ng new repro-app
  2. ng build -bh /testing/
  3. look at your /dist/index.html and see that the base tag looks as follows
    html <base href="C:/Program Files/Git/testing/">
    notice it has added the local directory to Git for some reason.

Desired functionality.

when using --base-href the value specified in the base element of index.html should be exactly the text typed in following the --base-href flag.

2 (required) broken

Most helpful comment

It seems to be an issue when running the command in git bash the same command works properly in powershell.

All 5 comments

Try something like: ng build -bh="testing" or ng build --base-ref="testing"

It seems to be an issue when running the command in git bash the same command works properly in powershell.

It's not an issue, its a feature of git bash on Windows. It's trying to help you out by converting Linux paths to Windows paths.

You can tell git bash to avoid the conversion for the -bh parameter by setting the MSYS2_ARG_CONV_EXCL environment variable while calling ng like this:
MSYS2_ARG_CONV_EXCL="-bh=" ng build --prod -bh="/en/"

Note that to use the exclusion you must use -bh parameter with an =, not space since MSYS2_ARG_CONV_EXCL will think the value after the space is a different parameter.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

elvisbegovic picture elvisbegovic  Â·  100Comments

DanielStep picture DanielStep  Â·  184Comments

hansl picture hansl  Â·  163Comments

ankeshdave picture ankeshdave  Â·  161Comments

Maistho picture Maistho  Â·  140Comments