-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Description
Bug Report or Feature Request (mark with an x
)
- [ x] bug report -> please search issues before submitting
- [ ] feature request
The ng build --prod is not respected. It does not set the proper production environment variable, so the dev properties are still used.
This is an Angular 4.x app built using the Angular/cli from the beginning, i.e: "App Works".
Versions.
_ _ ____ _ ___
/ \ _ __ __ _ _ | | __ _ _ __ / | | | |
/ ? \ | ' \ / _ | | | | |/ _
| '| | | | | | |
/ ___ | | | | (| | || | | (| | | | || | | |
// __| ||_, |_,||_,|| _|||
|___/
@angular/cli: 1.0.0
node: 7.8.0
os: win32 x64
Repro steps.
environments/environment.ts
const LOCALHOST = 'http://localhost:58810/api/';
export const environment = {
production: false,
Api: LOCALHOST
};
environments/environment.prod.ts
const ENDPOINT = 'https://my.azurewebsites.net/api/';
export const environment = {
production: true,
Api: ENDPOINT
};
In my header component I have the console.log of the environment:
import { environment } from './../../../../environments/environment';
import { Router } from '@angular/router';
import { Component, OnInit } from '@angular/core';
import { config } from './../../shared.config';
@Component({
selector: 'app-header',
templateUrl: './header.component.html',
styleUrls: ['./header.component.scss']
})
export class HeaderComponent implements OnInit {
version: string;
env: string;
constructor(
private _router: Router
) { }
ngOnInit() {
this.version = config.version;
console.log('env: ', environment.Api);
}
onLogout() {
this._router.navigate(['/auth/login']);
}
}
ng build --prod --aot=false
The log given by the failure.
No stack trace, but when I console.log the environment setting when deployed to Azure production, the result is: env: http://localhost:58810/api/
Desired functionality.
I would like to see the environment variable feature work. Let me know if I'm doing something wrong.