构建后未在lib中包含Angular 6库资产 [英] Angular 6 Library assets not included in lib after build
问题描述
我最近创建了一个Angular库(ng新库),并在使用 ng build --prod
构建它后遇到了问题.我的资产文件夹未复制到dist文件夹,并且我无法再引用我的文件.当我尝试在 angular.json
中包含 assets
脚本时,出现错误-模式验证失败
,并显示以下错误:
I have recently created an Angular library (ng new library) and had an issue after building it with the ng build --prod
. My assets folder did not get copied to the dist folder and I can no longer reference my file. When I tried including the assets
script in my angular.json
I got an error - Schema validation failed
with the following errors:
数据路径"不应具有其他属性(资产).
Data path "" should NOT have additional properties(assets).
是否可以在Angular库中包含资产?请帮助
Is there a way of including assets in an Angular library? Please help
推荐答案
现在, ng-packagr发布了一个新版本,该版本允许您将资产和构建文件包括在内:
Now, ng-packagr released a new version that allows you to include the assets along with the build files:
您可以使用资产选项复制这些资产.
{
"ngPackage": {
"assets": [
"CHANGELOG.md",
"./styles/**/*.theme.scss"
],
"lib": {
...
}
}
}
此处的更多信息: https://github.com/ng-packagr/ng-packagr/blob/master/docs/copy-assets.md
这篇关于构建后未在lib中包含Angular 6库资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!