Hi there, this this small snippets to learn about Angular package the library :)
-
first create blank angualr project
ng new demo --createApplication=false -
hit this command to create lib -
ng generate library my-lib -
then it will create library inside project directory -> inside library delete all files expect
my-lib.module.tsfile, then create following files -
my-lib.component.ts
my-lib.component.scss
my-lib.component.html
my-lib.component.spec.ts
//my-lib.module.ts- work on functionality that whatever you want do with above files after that you have to build your project - so hit followsing commands -
ng build my-libit will create following directory -
dist/<library-name>- Publishing your library to NPM
ng build my-lib
cd dist/my-lib
npm publish- You can build, test, and lint the project with CLI commands:
ng build my-lib
ng test my-lib
ng lint my-lib- Reference links - https://youtu.be/l3wjN4datGs