GithubHelp home page GithubHelp logo

azizkhani / angular-component-library Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mohanramphp/angular-component-library

1.0 1.0 0.0 190 KB

This repository is to understand how top built npm ready component library with Angular Eco System

License: MIT License

JavaScript 17.93% TypeScript 77.08% HTML 4.46% CSS 0.53%

angular-component-library's Introduction

AngularComponentLibrary

This project is to understand how to create npm ready angular component libraries to use in an angular application.

After, generating an angular application for the demo we will follow below steps to create component library

  1. Generate a library project by running following command
    ng generate library ratify --prefix=lib
  2. Library project will be created with one default exported component lib-ratify
  3. Lets write some code snippet to make lib-ratify to behave like a rating component.
  4. We can find the source code of rating component here
  5. To build the library run the below command
    ng build ratify
  6. Built is added to the dist folder of our application as dist/ratify
  7. There are two ways angular registers external libraries.
    1. NPM Module declarations in the package.json file.
    2. Library registered in the tsconfig.json file

    Note: Since we generated library with our application. Angular registered our library by placing library dependency entries in angular.json and tsconfig.json

  8. We have added few scripts to built the library and pack for npm in package.json
"scripts": {
    ...
    ...
    "build-lib": "ng build --prod ratify",
    "npm-pack": "cd dist/ratify && npm pack",
    "package": "npm run build-lib && npm run npm-pack"
  }

Last three commands (build-lib, npm-pack, package) are responsible for building and packing the library for npm

  1. Run npm run package to create npm ready library in dist/ratify

Finally, lets see how to publish npm package

  1. Add npm user by running below command
    npm adduser

Note:

  1. If you are not signed up above command will sign up you as npm user.
  2. Type npm whoami from a terminal to see if you are already logged in (technically, this also means that your credentials have been stored locally).
  1. Login into npm by running
    npm login
  2. Go to the packaged output in dist/ratify
> cd dist/ratify
> dist/ratify> npm publish

npm package will be uploaded to the npm registry - angular-ratify

angular-component-library's People

Contributors

mohanramphp avatar shahrishabhptechnical avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.