Yesterday I wrote about a pet project I'm working that is using Angular 19. Turns out that some things have changed compared to previous versions. But where I discovered yesterday that a new build output structure was used, today I struggled with the handling of static assets.
In older Angular versions, static application assets could be added to the src\assets
folder and loaded from there in your application html.
However starting from Angular 18 the src\assets
folder is no longer there, instead a new assets option configuration exists in your angular.json
. When creating a new project, this is configured by default to load assets from a public
folder:
The assets configuration is build up using a combination of 3 elements:
- glob: the pattern used to find matching files (e.g. **/*)
- input: the input directory where this pattern should be applied (e.g. public)
- output: the absolute path within the output where the matching assets should be copied to
This configuration gives us a lot of flexibility. So if you still like to use the assets folder instead, you can tweak the angular.json configuration like this: