I am creating a design library, and would like to include some basic SVG to it, so that if user do not add/override they will still be displayed as backup.
I created a folder in my library
assets/
=> svg/
=> alert.svg
=> success.svg
=> trash.svg
=> ...
I then added this folder to ng-package.json
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/libs/ui",
"assets": ["src/assets"],
"lib": {
"entryFile": "src/index.ts"
}
}
then I would like to load those svg in my library, so in my module folder I do :
constructor(private iconReg: SvgIconRegistryService) {
Object.entries({
alert: 'assets/svg/alert.svg',
info: 'assets/svg/info.svg',
success: 'assets/svg/success.svg',
warning: 'assets/svg/warning.svg',
}).forEach(([key, value]) => {
this.iconReg.loadSvg(value, key)?.subscribe();
});
}
Sadly, the src are not found when the library is used :
message: "Http failure response for http://localhost:4200/assets/svg/success.svg: 404 Not Found" name: "HttpErrorResponse"