docs: add ng-add save option (#38198)

PR Close #38198
This commit is contained in:
Tim Deschryver 2020-07-23 15:53:53 +02:00 committed by Misko Hevery
parent 4dfc3fe6a2
commit 1296003445
2 changed files with 23 additions and 2 deletions

View File

@ -16,5 +16,12 @@
"@angular/core": "^7.2.0"
},
// #docregion collection
"schematics": "./schematics/collection.json"
"schematics": "./schematics/collection.json",
// #enddocregion collection
// #docregion ng-add
"ng-add": {
"save": "devDependencies"
}
// #enddocregion ng-add
// #docregion collection
}

View File

@ -57,6 +57,20 @@ The task uses the user's preferred package manager to add the library to the pro
In this example, the function receives the current `Tree` and returns it without any modifications.
If you need to, you can do additional setup when your package is installed, such as generating files, updating configuration, or any other initial setup your library requires.
### Define dependency type
Use the `save` option of `ng-add` to configure if the library should be added to the `dependencies`, the `devDepedencies`, or not saved at all in the project's `package.json` configuration file.
<code-example header="projects/my-lib/package.json (ng-add Reference)" path="schematics-for-libraries/projects/my-lib/package.json" region="ng-add">
</code-example>
Possible values are:
* `false` - Don't add the package to package.json
* `true` - Add the package to the dependencies
* `"dependencies"` - Add the package to the dependencies
* `"devDependencies"` - Add the package to the devDependencies
## Building your schematics
To bundle your schematics together with your library, you must configure the library to build the schematics separately, then add them to the bundle.