DEV Community

Rudolf Olah
Rudolf Olah

Posted on

Creating a new library with Angular 6+

The directory structure for an Angular project changed in v6, so here's the process for creating a new library for Angular 6+:

~/Code$ ng new my-angular-library --create-application false
Enter fullscreen mode Exit fullscreen mode

When creating a new Angular project this way, the Angular CLI will not generate any application files, just the base project workspace.

Then you do this:

~/Code$ cd my-angular-library
~/Code$ ng g library my-lib
Enter fullscreen mode Exit fullscreen mode

The root directory, my-angular-library, can contain many projects which will be in the projects directory. The path to your new library will be projects/my-lib.

You can build the library by running ng build in the top-level workspace directory or in the projects/my-lib directory.

Oldest comments (0)