dimanche 22 mai 2016

Angular 2 component library

I am trying to create an Angular 2 Component library. This library would be consumed through npm by other people. The library would consist of some components with html and scss. The goal of the library is to provide the ability for the consumer to import the library through npm and then be able to use the components.

So far, i have made a library that has a component and is being consumed through npm. The consuming project can load the component and it is shown on the website.

Here are a couple of things i have NOT been able to accomplish:

  1. I was not able to use templateUrl for my html in the component because it was not being found inside the consumer project. I had to inline the html in the component.
  2. I am not seeing the styling from my scss or css that is in the library.

What do i need to do to accomplish my final two goals? I have put a lot of time, trial and error into this issue and need some assistance.

Here are my two projects that i have been working with. Feel free to create branches and submit them through github.

TheLibrary

TheConsumingProject

Let me know if you have any questions. Thanks for the help!


The why:

I am doing this because i am working on a project that will have several websites that share the same components. So, i figured i could break them out into a library and have them consumed. Is this a good way to do this, or is there a more widely accepted best practice?




Aucun commentaire:

Enregistrer un commentaire