.env 与 environment.ts 之间的 Angular 6 差异 [英] Angular 6 difference between .env vs environment.ts

查看:21
本文介绍了.env 与 environment.ts 之间的 Angular 6 差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从 https://mean.io 生成了一个项目.但我不确定 (.env 和 .env.example) 和 (environment.ts 和 environment.prod.ts) 之间有什么区别.

I generated a project from https://mean.io. But I am not sure what the difference is between (.env and .env.example) and (environment.ts and environment.prod.ts).

我应该在哪里存储我的所有配置数据、机密和密钥?

Where should I store all of my config data, secrets, and keys?

推荐答案

您应该将它们存储在 environment.ts

You should store them in the environment.ts

environment.ts如果您在 Angular 项目中引用环境对象属性,则在开发模式(即 ng serve 或 ng build)期间,应从该文件中读取所有值.

environment.ts If you refer environment object properties in your Angular project, during development mode i.e. ng serve or ng build all values shall be read from this file.

environment.prod.ts在这种情况下,当您使用 ng build --prod 为生产模式构建应用程序时,environment.ts 文件的所有值都将被 environment.prod.ts 文件覆盖.

environment.prod.ts When you build your application for production mode using ng build --prod in that case, all values of environment.ts file shall get overridden by environment.prod.ts files.

以上变量与您的 Angular 应用程序相关.而 .env 和 .env.example 用于 Laravel 应用程序.

The above variables are related to your Angular application. Whereas .env and .env.example are for the Laravel application.

.env 当您将项目推送到任何存储库时,它应该不受版本控制并被忽略.这是为了您的安全.

.env as it should be is out of version controlled and ignored when you push your project to any repository. This is for your own safety.

.env.example 包含非常通用的信息,在全新安装和一些更改时复制为 .env.前 APP_KE

.env.example which contains very generic information is copied as .env on fresh install and a few changes made. ex APP_KE

这篇关于.env 与 environment.ts 之间的 Angular 6 差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆