Please provide us with the following information:
Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
angular-cli: 1.0.0-beta.24
node: 5.11.1
os: darwin x64
@angular/common: 2.4.1
@angular/compiler: 2.4.1
@angular/core: 2.4.1
@angular/forms: 2.4.1
@angular/http: 2.4.1
@angular/platform-browser: 2.4.1
@angular/platform-browser-dynamic: 2.4.1
@angular/router: 3.4.1
@angular/compiler-cli: 2.4.1
update package.json to have
"build": "ng build --bh '${rootContext}/' --environment=prod --target=production",
line in script section
this will have correct output in index.html on Linux/OSX <base href="${rootContext}/">
but on windows its will be <base href="'${rootContext}/'">
if change package.json to have "build": "ng build --bh \"${rootContext}\/" --environment=prod --target=production", we will got correct otput on Windows but on Linux/OSX it will be <base href="">.
if package.json to have line like this "build": "ng build --bh ${rootContext}/ --environment=prod --target=production",, output will be invalid on both OS.
${rootContext} - is a var that will be replaced by java backend on server then return index.html to user.
How to make it works on any OS?
This sounds like a bug with how we parse the argument. Will need to investigate.
Windows 8.1, git-bash:
Command: ng build --base-href /foo/
Result: <base href="C:/Program Files/Git/foo/">
@filipesilva, any updates on this?
@s1im05 that happens in git bash because it parses arguments in a certain way - /foo/ really is C:/Program Files/Git/foo/.
@ptsydzik I had a quick look now and as far as I can tell the variables we get inside the CLI are 'correct'. What's happening is that Windows/Linux/OSX interpret quotes differently in npm scripts.
For npm scripts to work correctly with string args in Windows, they really need to be surrounded by \". That seems to not work so well with the ${var} notation in Bash though.
Not sure what we can do on the CLI side, the value we get is already the one interpreted by the terminal.
Maybe implement reading options from config file can help?
e.g.
ng build --build-config build.config.json
and in build.config.json do:
{
"baseHref": "\'${rootContext}\/\'",
"environment": "prod",
"target": "production",
.....
}
Thanks for reporting this issue. This issue is now obsolete due to changes in the recent releases. Please update to the most recent Angular CLI version.
If the problem persists after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior.
Still getting this issue with CLI v1.1.1
@filipesilva which v. of the CLI should this be fixed in?
Steps to reproduce, git bash Win 10:
$ ng new foo --style scss --routing --prefix foo
$ cd foo/ && ng build --prod --base-href=/something/here/
index.html shows <base href="C:/Program Files/Git/something/here/">
@danwulff what you're experiencing is https://github.com/angular/angular-cli/issues/5606.
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._
Most helpful comment
This sounds like a bug with how we parse the argument. Will need to investigate.