3

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

toti08
  • 2,448
  • 5
  • 24
  • 36

2 Answers2

0

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.

veben
  • 19,637
  • 14
  • 60
  • 80
0

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

German Quinteros
  • 1,870
  • 9
  • 33