I'm currently experimenting with creating Angular 6 libraries and consuming them in other applications. It seems to be working well. I am following: https://medium.com/@SirMaxxx/angular-6-creating-a-shareable-control-library-6a27f0ebe5c2
A problem that I am having is adding dependencies to such libraries, in particular with bootstrap.
What I am trying to do is to create a component library, which comes bundled with custom and 3rd party styles, however there does not seem to be a way to do that?
I would expect to add references to bootstrap to angular.json file similar to below:
"styles": [
"src/styles.css"
],
"scripts": []
..however Angular libraries do not contain angular.json files, which leads me to believe that such a thing is not possible/not supported/etc.
Help?
This is not supported "Out of the Box". I fiddled a bit around since I had to come up with a solution for one of my customers. In the end I found two posts pointing in the right direction. How to include a custom SCSS theme? and Medium Post of Dor3nz. The suggestion was to enrich the build process by introducing an extra custom build step for building tho Global Style file and copy it over to the dist folder. I did a small prototype and the approach is working quite good so far, at least in my case. Example could be found here Showcasing the approach. Hope it helps...
来源:https://stackoverflow.com/questions/51164896/angular-6-library-bootstrap-styles