Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assets folder does load on Angular 18

I was not able to load my images from the assets folder, I was using the Angular 18, after several atempts I was able to solve it.

Now on Angular 18 your assets folder needs to be on the path: public/

There is no needs to change angular.json See it here ...

like image 591
Ismael Nunes Avatar asked Nov 15 '25 10:11

Ismael Nunes


1 Answers

In Angular 18, the default folder for all assets is now outside the src directory and is called public. Previously, you would reference assets with a path like this:

Before:

<img src="assets/logo.png" alt="" srcset="">

Now:

<img src="/logo.png" alt="" srcset="">

Additionally, if you check the angular.json file, you will see that public is now the default folder for assets:

"assets": [
  {
    "glob": "**/*",
    "input": "public"
  }
]
like image 192
Abhishek joshi Avatar answered Nov 17 '25 10:11

Abhishek joshi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!