使用ng-packagr构建库时包括资产 [英] Include assets when building library using ng-packagr
问题描述
有人能提示从哪里开始使用ng-packagr将图像和CSS文件包括到Angular库中吗?
Could anyone give a hint where to start to include images and css files into Angular library using ng-packagr?
推荐答案
There's an official issue for that question here. It's actually quite simple to include images and the like to your library: You can just copy them to the dist folder manually after ng-packagr
has done its thing.
但是,在将要使用您的库的项目中自动提取这些文件更加困难.在上面提到的问题中,BenjaminDobler建议将以下映射添加到任何使用者项目的.angular-cli.json
文件中:
However, it's more difficult to automate the extraction of those files in projects that'll use your library. In the issue referenced above BenjaminDobler suggests to add the following mapping to the .angular-cli.json
file of any consumer project:
{ "glob": "**/*", "input": "../node_modules/my-lib/assets", "output": "./assets/my-lib/" }
不过,我觉得这更多的是NPM问题,还有一些裸露的NPM解决方案,例如 npm资产.
I feel this is more of an NPM issue, though, and there also are bare NPM solutions for it like pkg-assets and npm-assets.
这篇关于使用ng-packagr构建库时包括资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!