You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
HELPFUL: This is a minimal example, but the use of a schema for validation can be very powerful.
125
124
For more information, see the [JSON schemas website](http://json-schema.org).
@@ -128,36 +127,33 @@ To link our builder implementation with its schema and name, you need to create
128
127
129
128
Create a file named `builders.json` that looks like this:
130
129
131
-
<docs-codeheader="builders.json"language="json">
130
+
```json {header: "builders.json"}
132
131
133
132
{
134
-
"builders": {
135
-
"copy": {
136
-
"implementation": "./dist/my-builder.js",
137
-
"schema": "./src/schema.json",
138
-
"description": "Copies a file."
139
-
}
140
-
}
133
+
"builders": {
134
+
"copy": {
135
+
"implementation": "./dist/my-builder.js",
136
+
"schema": "./src/schema.json",
137
+
"description": "Copies a file."
138
+
}
139
+
}
141
140
}
142
-
143
-
</docs-code>
141
+
```
144
142
145
143
In the `package.json` file, add a `builders` key that tells the Architect tool where to find our builder definition file.
146
144
147
-
<docs-codeheader="package.json"language="json">
148
-
145
+
```json {header: "package.json"}
149
146
{
150
-
"name": "@example/copy-file",
151
-
"version": "1.0.0",
152
-
"description": "Builder for copying files",
153
-
"builders": "builders.json",
154
-
"dependencies": {
155
-
"@angular-devkit/architect": "~0.1200.0",
156
-
"@angular-devkit/core": "^12.0.0"
157
-
}
147
+
"name": "@example/copy-file",
148
+
"version": "1.0.0",
149
+
"description": "Builder for copying files",
150
+
"builders": "builders.json",
151
+
"dependencies": {
152
+
"@angular-devkit/architect": "~0.1200.0",
153
+
"@angular-devkit/core": "^12.0.0"
154
+
}
158
155
}
159
-
160
-
</docs-code>
156
+
```
161
157
162
158
The official name of our builder is now `@example/copy-file:copy`.
163
159
The first part of this is the package name and the second part is the builder name as specified in the `builders.json` file.
@@ -177,41 +173,37 @@ Architect in the Angular CLI uses the target definition to resolve input options
177
173
The `angular.json` file has a section for each project, and the "architect" section of each project configures targets for builders used by CLI commands such as 'build', 'test', and 'serve'.
178
174
By default, for example, the `ng build` command runs the builder `@angular-devkit/build-angular:browser` to perform the build task, and passes in default option values as specified for the `build` target in `angular.json`.
If you create a new project with `ng new builder-test`, the generated `angular.json` file looks something like this, with only default builder configurations.
0 commit comments