Skip to content

Commit 88463b7

Browse files
committed
Handle fingerprint when hot reloading scoped CSS bundles
1 parent 6fc6ff7 commit 88463b7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/BlazorWebView/src/SharedSource/StaticContentHotReloadManager.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,20 @@ private static (string AssemblyName, string RelativePath) GetAssemblyNameAndRela
8686
var requestPath = new Uri(requestAbsoluteUri).AbsolutePath.Substring(1);
8787
if (ContentUrlRegex.Match(requestPath) is { Success: true } match)
8888
{
89+
var assemblyName = match.Groups["AssemblyName"].Value;
90+
var relativePath = match.Groups["RelativePath"].Value;
91+
92+
// Remove the fingerprint from scoped CSS bundles, since CSS hot reload will send new content without the fingerprint.
93+
// LibraryName.<fingerprint>.bundle.scp.css -> LibraryName.bundle.scp.css
94+
if (relativePath.StartsWith($"{assemblyName}.", StringComparison.Ordinal) && relativePath.EndsWith(".bundle.scp.css", StringComparison.Ordinal))
95+
{
96+
relativePath = $"{assemblyName}.bundle.scp.css";
97+
}
98+
8999
// For RCLs (i.e., URLs of the form _content/assembly/path), we assume the content root within the
90100
// RCL to be "wwwroot" since we have no other information. If this is not the case, content within
91101
// that RCL will not be hot-reloadable.
92-
return (match.Groups["AssemblyName"].Value, $"wwwroot/{match.Groups["RelativePath"].Value}");
102+
return (assemblyName, $"wwwroot/{relativePath}");
93103
}
94104
else if (requestPath.StartsWith("_framework/", StringComparison.Ordinal))
95105
{

0 commit comments

Comments
 (0)