简体   繁体   English

将 angular.json 配置拆分为多个文件

[英]Split up angular.json configuration into multiple files

Status quo: I'm working on a project, which has different sub projects, which are assigned to different teams.现状:我正在做一个项目,它有不同的子项目,分配给不同的团队。 So my angular.json looks something like this:所以我的 angular.json 看起来像这样:

{
  ....
  "projects": {
    "project-1": { ... }
    "project-2": { ... }
  ....

Is there a way to move the configuration for project-1 into it's own file.有没有办法将 project-1 的配置移动到它自己的文件中。

Reason: This would allow us to make the approval process better, where we can define CODEOWNERS per file, but not per file part.原因:这将使我们能够更好地改进审批流程,我们可以定义每个文件的 CODEOWNERS,但不能定义每个文件部分。 Since angular.json is over all projects, it needs the most approvals, which usually just ends up with the responsible team asking us to approve the change, because they changed the configuration responsible for them.由于 angular.json 涉及所有项目,因此需要最多的批准,通常最终只需要负责团队要求我们批准更改,因为他们更改了负责他们的配置。

As far as I am aware, this is not supported in Angular directly.据我所知,Angular 不直接支持此功能。

There is a build framework called Nx that does support this kind of destructuring.有一个名为 Nx 的构建框架确实支持这种解构。 Instead of angular.json , you can create a workspace.json that supports an extended syntax:您可以创建一个支持扩展语法的workspace.json ,而不是angular.json

angular.json

Your angular.json file can be renamed to workspace.json and Nx will process it in the same way.您的angular.json文件可以重命名为workspace.json 。json 和 Nx 将以相同的方式处理它。 The workspace.json has one additional top level property version . workspace.json有一个额外的顶级属性version Setting version to 1 means the workspace.json file syntax is identical to angular.json When the version of workspace.json is set to 2, targets , generators and executor properties are used instead of the version 1 properties architect , schematics and builder . Setting version to 1 means the workspace.json file syntax is identical to angular.json When the version of workspace.json is set to 2, targets , generators and executor properties are used instead of the version 1 properties architect , schematics and builder .

project.json

In version 2 workspaces, project configurations can also be independent files, referenced by angular.json .在版本 2 工作空间中,项目配置也可以是独立文件,由angular.json引用。 For instance, an angular.json may contain projects configured as below.例如, angular.json可能包含配置如下的项目。

 json { "projects": { "mylib": "libs/mylib" } }

Reference: https://nx.dev/l/a/core-concepts/configuration参考: https://nx.dev/l/a/core-concepts/configuration

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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