0
ng build --env=prod
始終選擇environment.ts
而不是environment.prod.ts
這是一個錯誤?Angular4啓用生產模式
我猜它,因爲main.ts進口environment.ts
默認
import { environment } from './environments/environment';
main.ts
import './polyfills.ts';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/home/app.module';
import { enableProdMode } from '@angular/core';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
console.log(environment);
}
platformBrowserDynamic().bootstrapModule(AppModule);
environment.prod.ts
export const environment = {
production: true,
apiURL : '/offer-screener-web/'
};
個
environment.ts
export const environment = {
production: false,
apiURL : '/offer-screener-web/'
};
.angular-CLI
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"qa": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
納克-v
@angular/cli: 1.4.4
node: 8.5.0
os: darwin x64
@angular/cli: 1.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/compiler-cli: 4.3.6
typescript: 2.1.6
憑着這兩種工作,這裏的問題github上https://github.com/angular/angular-cli/issues/7920 –