We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
假设有三个环境:开发环境(dev)、测试环境(test)、生产环境(prod)。 当我们构建参数时会用到 --environment来指定应用执行环境。脚手架会根据指定的值加载对应的环境配置文件。如:ng build --env=dev 就是build开发环境的包。那么我们就从这里开始看看Angular项目里环境该怎么配置。
"environmentSource": "environments/environment.ts", // 基础环境配置 "environments": { // 子环境配置文件 "dev": "environments/environment.ts", "test": "environments/environment.test.ts", "prod": "environments/environment.prod.ts" }
{ "title": "", "question": { "url": "" }, "list": { "pageSize": 10 } }
开发环境 :
export const environment = Object.assign({}, require('./common.json'), require('./development.json'), { production: false, envName: 'dev' });
{ "baseUrl": "/", "env": "dev", "api": { "host": "http://localhost:4200" } }
测试环境:
export const environment = Object.assign({}, require('./common.json'), require('./test.json'), { production: false, envName: 'test' });
{ "baseUrl": "/", "env": "test", "api": { "host": "testurl" } }
生产环境:
export const environment = Object.assign({}, require('./common.json'), require('./production.json'), { production: true, envName: 'prod' });
{ "baseUrl": "/", "env": "prod", "api": { "host": "produrl" } }
... @Injectable() export class LoginService { public Login(): Observable<any> { return this.http.get("/login").map( response => { return response.json(); } ) } }
(完)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
文件目录:
├─ environments
│ ├─ common.json
│ ├─ environment.ts
│ ├─ development.json
│ ├─ environment.test.ts
│ ├─ test.json
│ ├─ environment.prod.ts
│ └─ production.json
│
开发环境 :
测试环境:
生产环境:
(完)
The text was updated successfully, but these errors were encountered: