ng build --prod --base-href includes absolute path of building cwd
Bug Report or Feature Request (mark with an x)
- [x] bug report -> please search issues before submitting
- [ ] feature request
Command (mark with an x)
- [ ] new
- [x] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
Versions
Windows 10, GIt Bash
$ ng --version
Angular CLI: 6.2.3
Node: 8.12.0
OS: win32 x64
Angular: 6.1.8
Repro steps
Build project by the following command:
ng build --prod --base-href /client1-app
The log given by the failure
n/a
Desired functionality
Application need to be deployed under http://example.com/client1-app. The base path for it should be /client1-app then.
However in index.html wrong base path is included:
$ grep base dist/election-barometer/index.html
<base href="E:/Programs/Git/client1-app">
The git installation path (absolute path of installation dir) is included when --base-href starts with slash character.
Base href cannot be just client1-app (without slash at the beggining), because of routing. User can start application from:
/client1-app/some/path/started
Then, client1-app will point to example.com/some/path/client1-app
Which is not intended, so slash at the beggining is required.
Mention any other details that might be useful
The following repository could be useful during investigation: https://github.com/athlan/election-barometer However, nothing special on it, was generated by ng cli.
Noticed this as well, but only happened when using bash. Seems to work as expected in PowerShell.
Massive of people uses git bash on windows. Scale is huge. At least good to know the source of this variable, maybe could be fixed easly or overcomed.
For now I am waiting for maintainers' response before deciding to make a PR (if it's worth even to get review for merge).
@athlan, unfortunately today I don't have access to my Windows machine, however I think what is happening is that Git Bash is resolved the paths in the arguments to absolutes.
Can you try if the follow solved the issue?
ng build --prod --base-href '/client1-app'
Hello,
Checked that and ng build --prod --base-href '/client1-app' and ng build --prod --base-href "/client1-app" results with the same issue.
By the way, where this fragment of code is actually generated? https://github.com/search?p=1&q=org%3Aangular+base-href&type=Code
I'm sorry to say but this is a duplicate of https://github.com/angular/angular-cli/issues/5606 and https://github.com/angular/angular-cli/issues/6060.
This isn't the thing we can truly fix on our side. Git Bash converts the commands and what is actually passed into the node executable is already the full path you see. You can read more about this problem and some possible workarounds in the issues I mentioned.
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.