简体   繁体   中英

How do I create an app specific configuration for Angular with NX/Nrwl?

So I have the following project structure:

apps
├── car
└── [...]
libs
├── app-car
├── [...]
└── shared
    ├── config
    └── [...]

For every app I want to provide a different config, that can be used in the grouped libs.

export interface DefaultAppConfig {
  language: string;
}
export interface CarAppConfig extends DefaultAppConfig  {
  dealerShipName: string;
}

This is how I provide the config for every app.

But how can I typecast the config (placed in shared/config ) that the CarAppConfig is used only for the group app-car and DefaultAppConfig for shared ?

From what I can understand, IMHO, you should keep DefaultAppConfig in shared/config and CarAppConfig in app-car .

Reason: As the name suggest, shared is shared by all libs . So, why should other app have access to an object which is out of its scope.

You can extend DefaultAppConfig in all apps and use it in its app-car.module or something.

Side note: You can also explore the concept of Tags to have more control over what can be imported into a lib and what should not.

Please let me know if I get it correctly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM