You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aspnetcore/blazor/class-libraries.md
+26-1Lines changed: 26 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ description: Discover how components can be included in Blazor apps from an exte
5
5
monikerRange: '>= aspnetcore-3.0'
6
6
ms.author: riande
7
7
ms.custom: mvc
8
-
ms.date: 05/06/2019
8
+
ms.date: 06/09/2019
9
9
uid: blazor/class-libraries
10
10
---
11
11
# Razor components class libraries
@@ -126,3 +126,28 @@ dotnet nuget publish
126
126
```
127
127
128
128
When using the `blazorlib` template, static resources are included in the NuGet package. Library consumers automatically receive scripts and stylesheets, so consumers aren't required to manually install the resources. Note that [static assets aren't supported for server-side apps](#static-assets-not-supported-for-server-side-apps), including when a Blazor library (`blazorlib`) is referenced by a server-side app.
129
+
130
+
## Create a Razor class library with static assets
131
+
132
+
Razor class libraries (RCL) frequently require companion static assets that can be referenced by the consuming app of the RCL. ASP.NET Core allows creating RCLs that include static assets that are available to a consuming app.
133
+
134
+
To include companion assets as part of a Razor class library, create a *wwwroot* folder in the class library and include any required files in that folder.
135
+
136
+
When packing a Razor class library, all companion assets in the *wwwroot* folder are included in the package automatically and are made available to apps referencing the package.
137
+
138
+
### Consume content from a referenced Razor class library
139
+
140
+
The files included in the *wwwroot* folder of the Razor class library are exposed to the consuming app under the prefix `_content/{LIBRARY NAME}/`. The consuming app references these assets via `<script>`, `<style>`, `<img>`, and other HTML tags.
141
+
142
+
### Multi-project development flow
143
+
144
+
When the app runs:
145
+
146
+
* The assets stay in their original folders.
147
+
* Any change within the class library *wwwroot* folder is reflected in the app without rebuilding.
148
+
149
+
At build time, a manifest is produced with all the static web asset locations. The manifest is read at runtime and allows the app to consume the assets from referenced projects and packages.
150
+
151
+
### Publish
152
+
153
+
When the app is published, the companion assets from all referenced projects and packages are copied into the *wwwroot* folder of the published app under `_content/{LIBRARY NAME}/`.
0 commit comments