Angular Schulungen, Workshops und Beratung in Deutschland, Österreich und der Schweiz
This blog post is part of an article series.
It’s always the same: After npm installing a new library, we have to follow a readme step by step to include it into our application. Usually this involves creating configuration objects, referencing css files, and importing Angular Modules. As such tasks aren’t fun at all it would be nice to automate this.
This is exactly what the Angular CLI supports beginning with Version 6 (Beta 5). It gives us a new command that fetches an npm package and sets it up with a schematic — a code generator written with the CLI’s scaffolding tool Schematics. To support this, the package just needs to name this schematic .
In this article, I show you how to create such a package. For this, I’ll use ng-packagr and a custom schematic. You can find the source code in my GitHub account.
If you haven’t got an overview to Schematics so far, you should lookup the well written introduction in the Angular Blog before proceeding here.
To demonstrate how to leverage , I’m using an example with a very simple logger library here. It is complex enough to explain how everything works and not indented for production. After installing it, one has to import it into the root module using :
As you see in…