Adding static files
Blazor can use static files, such as images, CSS, and JavaScript. If we put our files in the wwwroot
folder, they will automatically be exposed to the internet and be accessible from the root of our site. The nice thing about Blazor is that we can do the same with a library; it is super easy to distribute static files within a library.
At work, we share components between all of our Blazor projects, and the shared library can also depend on other libraries. By sharing components and building our own components (sometimes on top of other libraries), we ensure we have the same look and feel throughout a site. We also share static content like images and CSS, and this makes it simple and fast if we need to change something and we want all of our sites to be affected.
To link to a resource in another library/assembly, we can use the _content
folder.
Take a look at this example:
<link rel="stylesheet" href="_content/SharedComponents...