DonkeyCode
Menu

Le blog Développement Angular

Create reusable components with a Library

Extraire ses composants Angular réutilisables dans une bibliothèque partagée entre plusieurs applications : création, build et publication npm.

Illustration de Create reusable components with a Library

For that purpose, we will use :

Why angular-cli ? Because it avoid us to think about build configuration and everything else. It makes new projectss that have testing, AoT, transpilation and linting already configured.

Why ng-packagr ? Because it build our Library to an Angular Package Format and everything that is needed (minification, sourcemaps, ...)

Why angular-library-starter-kit ? Because it make everything out of the box, with autodeploy and a demo page !

Autodeploy to GitHub Pages

Generate a token here. Scopes: [x] repo.

gem install travis
travis encrypt GH_TOKEN=your_token_here

The result should be copy-pasted into env -> global -> secure in .travis.yml

Autodeploy to NPM

Generate a token with npm token create.

travis encrypt your_token_here

The result should be copy-pasted into deploy -> api_key -> secure in .travis.yml

Results !

https://raphaelyan.github.io/ngx-deck/

https://www.npmjs.com/package/ngx-deck

Lib installed

En parler avec nous

Vous vous posez la même question ?

Racontez-nous votre situation. On vous dira dans le même échange si c'est un sujet pour nous, et par quoi on commencerait.

Parlons de votre projet

ou choisissez un créneau tout de suite