zl程序教程

您现在的位置是:首页 >  移动开发

当前栏目

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

AngularApp The with an Time at CLI
2023-09-14 08:59:17 时间

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",