Reputation: 11
I have an angular library named common-sec in which created assets folder manually under the lib folder. I used images from the assets folder in my library component named "login".
I have used a login component from the common-sec library in my main angular app.
By running the main app with ng serve, library images of assets folder loading perfectly. But when I build my main app using ng build --prod --base-href /prefix/, none of the library images rendered.
I see it tries to request images at localhost:4200/assets/image.png (return 404) But I see images are available at localhost:4200/prefix/assets/image.png
Is it a bug or it's known issue in angular-cli?
Upvotes: 1
Views: 1169
Reputation: 1
Are you using an absolute path inside any library component?
Base-href will replace the absolute paths at build time.
The libraries ng build
process from AngularCLI doesn't allow --base-href
as a parameter, only for projects. So when you apply it to your project build, the libraries are already built (without replacing absolute paths).
You can use your own script to replace them before building the libraries.
Upvotes: 0