From ec233ebc3cf092c75c603ed3ad59a42ece543bf4 Mon Sep 17 00:00:00 2001 From: Robert Foster Date: Thu, 23 Jul 2026 08:46:41 +1000 Subject: [PATCH] Version 0.4.0 added UseViteUnhashedAssetRedirects() --- README.md | 30 ++- Vite.dotnet.Tests/ManifestTestContext.cs | 44 +++-- .../UnhashedAssetRedirectTests.cs | 184 ++++++++++++++++++ Vite.dotnet/Extensions.cs | 75 +++++++ Vite.dotnet/ServiceExtensions.cs | 51 ----- Vite.dotnet/Services/IViteManifestService.cs | 7 + Vite.dotnet/Services/ViteManifestService.cs | 87 ++++++++- Vite.dotnet/Vite.dotnet.csproj | 2 +- .../ViteUnhashedAssetRedirectMiddleware.cs | 33 ++++ 9 files changed, 447 insertions(+), 66 deletions(-) create mode 100644 Vite.dotnet.Tests/UnhashedAssetRedirectTests.cs create mode 100644 Vite.dotnet/Extensions.cs delete mode 100644 Vite.dotnet/ServiceExtensions.cs create mode 100644 Vite.dotnet/ViteUnhashedAssetRedirectMiddleware.cs diff --git a/README.md b/README.md index 074e963..2190b29 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ Options bind from the `ViteManifest` section of `appsettings.json`: | `DefaultEntry` | `index.html` | The logical entry assumed by the parameterless service getters. | | `DefaultBasePath` | `/` | The base path hashed assets are served from when none is supplied. | -Registration overloads (`ViteServiceExtensions`): +Registration overloads (`ViteServiceCollectionExtensions`): ```csharp // Defaults only @@ -141,10 +141,38 @@ Returned URLs are prefixed with the supplied base path. Pass `""` as the base pa | `GetCssFiles()` / `(entry, basePath)` / `(ViteManifestEntry, basePath)` | `IReadOnlyList`| Resolved CSS URLs. | | `GetJsFile()` / `(entry, basePath)` / `(ViteManifestEntry, basePath)` | `string?` | Resolved JS URL. | | `GetModulePreloadFiles(ViteManifestEntry, basePath)` | `IReadOnlyList`| Transitively-imported chunk URLs (for modulepreload). | +| `TryResolveHashedAsset(requestPath, out hashedPath)` | `bool` | Resolve an unhashed asset path to its hashed build output. | | `RenderCss(entry, basePath, preload)` | `IHtmlContent` | CSS `` tags only. | | `RenderJs(entry, basePath)` | `IHtmlContent` | `` for imported chunks + the module `