Angular 2 project as library. #590
Comments
You could open either of those projects in Visual Studio technically, an Angular library would be just a series of JS files (once everything is transpiled), which then gets published to NPM. These templates are more-so designed to make .NET & Angular applications, you can't use .NET and other things in libraries. Have you tried opening those generators in VSCode, should also be a nice experience! |
I know that .NET does't need to be in library, and I don't need it. Just want to maintain a library using VS and running it in .NET, and then when publish angular library just simply ignore .NET files. Yes, I have tried to open it in VSCode, and managed to run and publish it to npm. But my boss would like to maintain it in VS, and I am struggling to find a way to setup a base project and insert this library example. Still playing around with your project trying to achieve this. |
Ahh ok yeah I understand, was just wondering! Let me try and open a library in VS and see if I can help as well. |
I have managed to setup your seed project to create a library. I have used npm publish to publish component and consume it in another project. I will create a repository with the example later on and explain what kind of changes I've done if someone will be interested in the future. Not sure if it is perfect way of doing it, but it works. Need to gather more information how to do proper way. |
https://github.com/Antoshjkee/angular2-library-example/
So in the end i got this. https://www.npmjs.com/package/ng2-another-test-component Installed library looks like this
Installed in another project and imported like this
and in HTML And it works! I know it could be done better way, just need to understand how :) |
If anyone can suggest me how can I minify/uglify and add CSS and HMTL to components js file without bundling into one big file, I would appreciate this! |
Glad you found an approach that works for you. I'll mark this as closed as it's doesn't relate to some issue in the code in this repo (though you're welcome to continue discussing it here if you want!). |
Hello,
Can I use your Angular 2 project to build a separate library for another application. I looked at couple examples :
https://github.com/jhades/angular2-library-example
https://github.com/jvandemo/generator-angular2-library
But I want to be able to maintain library in Visual Studio using your build.
Can you advice me how can I setup your build to simply use it as a library and publish to npm if needed.
Thank you!
The text was updated successfully, but these errors were encountered: