[英]How to configure the Angular 2 environment setting by angular-cli?
I try to use angular-cli to configure the environment setting from https://github.com/angular/angular-cli#build-targets-and-environment-files 我尝试使用angular-cli来配置环境设置,从https://github.com/angular/angular-cli#build-targets-and-environment-files
But after I run "ng build --prod -aot", the output pages still show the content from original environment/environment.ts. 但是在我运行“ng build --prod -aot”之后,输出页面仍然显示来自原始环境/ environment.ts的内容。 I expect this file will be overwritten by environment/environment.prod.ts, but it looks like not.
我希望这个文件会被environment / environment.prod.ts覆盖,但看起来不是。
My folder structure is like: 我的文件夹结构如下:
- angular-cli.json
角cli.json
- ...
...
- src/
SRC /
- app/
应用程序/
- ...
...
- environment/
环境/
- environment.dev.ts
environment.dev.ts
- environment.prod.ts
environment.prod.ts
- environment.ts
environment.ts
- main.ts
main.ts
- ...
...
My angular-cli.json: 我的角度cli.json:
"apps": [
{
"root": "src",
...,
"environments": {
"dev": "environments/environment.dev.ts",
"prod": "environments/environment.prod.ts"
}
...
In my main.ts file, I import the "environment": 在我的main.ts文件中,我导入了“环境”:
import { environment } from './environments/environment';
And here is my ng version: 这是我的版本:
angular-cli: 1.0.0-beta.22-1 node: 6.9.1 os: win32 x64
angular-cli:1.0.0-beta.22-1节点:6.9.1 os:win32 x64
Does any one know what's wrong with me? 有人知道我有什么问题吗? Really thanks.
真的感谢。
在environment数组中添加source元素:
"source": "environments/environment.ts",
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.