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

标签 angular nrwl-nx nrwl

所以我有以下项目结构:

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

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

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

This这就是我为每个应用程序提供配置的方式。

但是我如何才能强制转换CarAppConfig 仅用于组app-car 的配置(放置在shared/config 中)和 DefaultAppConfigshared?

最佳答案

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

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

您可以在所有应用程序中扩展 DefaultAppConfig 并在它的app-car.module 或其他东西中使用它。

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.

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

关于angular - 如何使用 NX/Nrwl 为 Angular 创建应用程序特定配置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69972966/

相关文章:

angular - 如何创建无容器的 Angular 6+ 组件?

angular - 运行 "Invalid options provided"时获取 "yarn affected-depgraph"

angular - *ngFor中输入无法顺利打字Angular 2

angular - 如何在 Angular 4 中检查滚动是否结束?

node.js - 如何解决以下错误 : Cannot find module '@nx/node/src/executors/node/schema.json'

nestjs - 使用 nrwl nx 构建 nestjs 应用程序时,process.env.NODE_ENV 总是 'development'

nestjs - 在 nx 构建/部署上生成 package.json

nrwl-nx - 如何在自定义 Nx 生成器中生成 Angular 应用程序?

jenkins - 在 Jenkins 中使用 Nx 进行 CI/CD 的最佳方式

angular - 返回的 BehaviorSubject(作为 Observable)是否受 take(1) 或取消订阅的影响?