Tuesday 21 February 2023

Angular custom npm library create and publish to npmjs artifactory

 

Create AngularLibrary from existing angular project

Assumtion : ng new Angular-App (created working with sample boiler plate code)

ng g library ngx-logger-matui

It create angular-app-> project -> ngx-logger-mat

Src src/lib ng-packagr.json package.json ... ..

to add dependent npm libraries go to angular-app->project->src->lib

npm i @material-ui, ....

then add it ng-package export ,

components, service, pipes, models we can use it.


Publish AngularLibrary

Sing up at npmjs.com

email, user, pwd are required, Email has to be verify with link

Build AngularLibrary

Angular app or workspace do angular library build

ng build ng-logger (pacakge.json at library ngs-logger-gn) to avoid naming convention

go to workspace->dist->library

cmd:>npm publish username : npmjs username &password: ****,& email public: mandate to get OTP to publish

No comments:

Post a Comment