问题
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).
Is there a way of including assets in an Angular library? Please help
回答1:
I had the same issue with Angular CLI 6.1.3. Change your assets part in your angular.json file :
"assets": [
"src/favicon.ico",
"src/web.config",
"src/assets"
],
It works even if you don't have a web.config file.
回答2:
Now, ng-packagr released a new version that allows you to include the assets along with the build files:
You can copy these assets by using the assets option.
{
"ngPackage": {
"assets": [
"CHANGELOG.md",
"./styles/**/*.theme.scss"
],
"lib": {
...
}
}
}
More information here: https://github.com/ng-packagr/ng-packagr/blob/master/docs/copy-assets.md
来源:https://stackoverflow.com/questions/52289213/angular-6-library-assets-not-included-in-lib-after-build