In Angular 12, how do I ship my library's assets?

Discussão em 'Angular' iniciado por Lucas Pottersky, Maio 6, 2025.

  1. I have a standard Angular 12 library workspace that I created through "ng generate library my-lib".

    my-lib has a component that shows an image asset.

    My consumer app uses my-lib component but the image fails to load (404). It looks like the assets isn't being packaged.

    Here is my projects/my-lib/ng-package.json:

    {
    "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
    "dest": "../../dist/pje-gateway-componentes",
    "lib": {
    "entryFile": "src/public-api.ts"
    },
    "assets": ["./assets/"]
    }

    • OBS1: i wouldn't like to base64 encode the image.
    • OBS2: i wouldn't like to have the image sit in the consumer app.

    Continue reading...

Compartilhe esta Página