Angular-cli: --base-href option results into wrong base-href in index.html

Created on 24 Apr 2017  路  7Comments  路  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

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

Versions.

$ ng --version
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ 芒鲁 \ | '_ \ / _| | | | |/ _ | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ __| |_|__, |__,_|_|__,_|_| ____|_____|___|
|___/
@angular/cli: 1.0.0
node: 6.9.3
os: win32 x64
@angular/common: 2.4.10
@angular/compiler: 2.4.10
@angular/compiler-cli: 2.4.10
@angular/core: 2.4.10
@angular/forms: 2.4.10
@angular/http: 2.4.10
@angular/platform-browser: 2.4.10
@angular/platform-browser-dynamic: 2.4.10
@angular/platform-server: 2.4.10
@angular/router: 3.4.10
@angular/cli: 1.0.0

Repro steps.

Create a new project and build it with this command:
ng build --env prod --base-href /test/

This results into the following base href:

<base href="C:/Program Files/Git/test/">

The log given by the failure.

  • no error

Desired functionality.

Result should be
<base href="/test/">

### Mention any other details that might be useful.

Most helpful comment

Dupe of https://github.com/angular/angular-cli/issues/5606.

This is, unfortunately, very much a git bash problem. The string that reaches the CLI isn't /test/ but C:/Program Files/Git/test/.

Workarounds are:

  • use two slashes so gitbash doesn't replace it: ng build --base-href //test/
  • setup a npm script: "build-base-href": "ng build --base-href=/test/"

All 7 comments

Ok. This seems to be a particular problem with git bash. Any ideas on resolving this?

I'm seeing this as well after upgrading to CLI v 1.0, worked before on the beta releases.

Also using git bash

$ ng --version

@angular/cli: 1.0.0
node: 7.4.0
os: win32 x64
@angular/common: 4.0.1
@angular/compiler: 4.0.1
@angular/core: 4.0.1
@angular/forms: 4.0.1
@angular/http: 4.0.1
@angular/platform-browser: 4.0.1
@angular/platform-browser-dynamic: 4.0.1
@angular/router: 4.0.1
@angular/cli: 1.0.0
@angular/compiler-cli: 4.0.1

Nevertheless I think this is a problem with git bash, not with angular cli since it works in cmd.

Nevertheless it worked on CLI beta with the same version of Git bash, so seems something changed on the CLI side.
Anyone know which files this is setup?
Did a quick search in source and base-href pops up all over the place.. Hard for a rookie to know where to look 馃樀

Dupe of https://github.com/angular/angular-cli/issues/5606.

This is, unfortunately, very much a git bash problem. The string that reaches the CLI isn't /test/ but C:/Program Files/Git/test/.

Workarounds are:

  • use two slashes so gitbash doesn't replace it: ng build --base-href //test/
  • setup a npm script: "build-base-href": "ng build --base-href=/test/"

Dupe of #5606.

This is, unfortunately, very much a git bash problem. The string that reaches the CLI isn't /test/ but C:/Program Files/Git/test/.

Workarounds are:

  • use two slashes so gitbash doesn't replace it: ng build --base-href //test/
  • setup a npm script: "build-base-href": "ng build --base-href=/test/"

In my case the two slashes didn't worked but the second option works like a charm, thank you.

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

gotschmarcel picture gotschmarcel  路  3Comments

brtnshrdr picture brtnshrdr  路  3Comments

IngvarKofoed picture IngvarKofoed  路  3Comments

rajjejosefsson picture rajjejosefsson  路  3Comments

purushottamjha picture purushottamjha  路  3Comments