如何使用 NX/Nrwl 为 Angular 创建应用程序特定配置?

2024-01-09

所以我有以下项目结构:

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

对于每个应用程序,我想提供不同的配置,可以在分组库中使用。

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

This https://stackoverflow.com/a/54793384/8408576这就是我为每个应用程序提供配置的方式。

但是我怎样才能类型转换配置(放置在shared/config)即CarAppConfig仅用于组app-car and DefaultAppConfig for shared?


据我所知,恕我直言,你应该保留DefaultAppConfig in shared/config and CarAppConfig in app-car.

原因:顾名思义,共享就是由所有库共享。那么,为什么其他应用程序应该有权访问超出其范围的对象。

You can extend DefaultAppConfig在所有应用程序中并在其应用程序中使用它app-car.module或者其他的东西。

旁注:您还可以探索以下概念:Tags https://nx.dev/l/a/structure/monorepo-tags#tags更好地控制什么可以导入到库中,什么不应该导入到库中。

如果我理解正确,请告诉我。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何使用 NX/Nrwl 为 Angular 创建应用程序特定配置? 的相关文章

随机推荐