[英]How to configure the Angular 2 environment setting by angular-cli?
我嘗試使用angular-cli來配置環境設置,從https://github.com/angular/angular-cli#build-targets-and-environment-files
但是在我運行“ng build --prod -aot”之后,輸出頁面仍然顯示來自原始環境/ environment.ts的內容。 我希望這個文件會被environment / environment.prod.ts覆蓋,但看起來不是。
我的文件夾結構如下:
- 角cli.json
- ...
- SRC /
- 應用程序/
- ...
- 環境/
- environment.dev.ts
- environment.prod.ts
- environment.ts
- main.ts
- ...
我的角度cli.json:
"apps": [
{
"root": "src",
...,
"environments": {
"dev": "environments/environment.dev.ts",
"prod": "environments/environment.prod.ts"
}
...
在我的main.ts文件中,我導入了“環境”:
import { environment } from './environments/environment';
這是我的版本:
angular-cli:1.0.0-beta.22-1節點:6.9.1 os:win32 x64
有人知道我有什么問題嗎? 真的感謝。
在environment數組中添加source元素:
"source": "environments/environment.ts",
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.