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

查看:262
本文介绍了.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?

推荐答案

您应将它们存储在环境中.ts

You should store them in the environment.ts

environment.ts 如果您在Angular项目中引用环境对象属性,则在开发模式(即serv或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天全站免登陆