Tom*_*Tom 6 environment angular
我有一个 Angular 8 应用程序并测试在 environment.ts 文件中设置的超时。我目前已将超时设置为 6 分钟。我有两个环境文件,即 environment.ts 和 enviornment.prod.ts。我相信执行 ng build --prod 时会使用 environment.prod.ts 。
运行 ng build 命令后,我无法在分发文件夹中找到环境文件。有人可以告诉我在哪里可以找到它吗?它是在某些二进制文件中吗?
这就是我的环境文件的样子
// The file contents for the current environment will overwrite these during build.
// The build system defaults to the dev environment which uses `environment.ts`, but if you do
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
// The list of which env maps to which file can be found in `.angular-cli.json`.
export const environment = {
production: false,
baseUrl: "http://localhost:57973",
loginUrl: "/Login",
adminUrl: "/Admin",
userIdleMinutes: 10
};
Run Code Online (Sandbox Code Playgroud)
首先,您需要environment.ts在代码中实际使用您的文件。例如:
import { Component } from '@angular/core';
import { environment } from '../environments/environment';
@Component({})
export class AppComponent {
env = environment;
constructor() {
console.log(this.env.baseUrl);
}
}
Run Code Online (Sandbox Code Playgroud)
否则,未使用的代码将被进行tree-shaking。
然后,该environment.ts文件中的代码将被捆绑到 main-XXXXX.js 文件中。
| 归档时间: |
|
| 查看次数: |
8458 次 |
| 最近记录: |