[Angular] Configure an Angular App at Compile Time with the Angular CLI

Compile time configuration options allow you to provide different kind of settings based on the environment you're building the Angular app for. You might for instance have a development, staging and production environment. With the Angular CLI you're already perfectly set up. Whenever you compile your app, you just pass the --env=<your-environment> to the CLI. The according settings will then be compiled into your app. But let's take a closer look how that works and how you can define new environments by yourself

You can add env setting in environement folder, or even create new environement file.

For example:

//environment.staging.ts

export const environment = {
  production: true,
  appTitle: 'NG app (staging)'
};

Run the env:

"build:staging": "ng build --prod --env=staging",
原文地址:https://www.cnblogs.com/Answer1215/p/8337466.html