Angular 9 how to include fonts during library build

1k Views Asked by At

I´m trying to use my angular library for an external project. I would like this project can use directly fonts from my library. I noticed the folder projects/my-library/src/lib/styles/fonts is not included when I build my library.

I tried to follow answers of this similar question without success. I tried this :

ng-package.json

{
  "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
  "dest": "../../dist/my-library",
  "assets": [
    "./src/lib/styles/fonts/**"
  ],
  "lib": {
    "entryFile": "src/public-api.ts",
    "styleIncludePaths": ["node_modules", "src/lib/styles"]
  }
}

In this case, I have a directory src/... created in dist/my-library and I got this error:

An unhandled exception occurred: EEXIST: file already exists, mkdir 'path/to/dist/my-library/src/lib/styles/fonts'

or

{
  "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
  "dest": "../../dist/my-library",
  "lib": {
    "entryFile": "src/public-api.ts",
    "styleIncludePaths": ["node_modules", "src/lib/styles"],
    "cssUrl": "inline"
  }
}

I got this error :

WARNING: postcss-url: ... Can't read file 'path/to/font.eot'

Someone knows the way to properly include fonts or others assets for library build like inside dist/my-library/lib/styles/fonts ?

0

There are 0 best solutions below