Skip to content

Commit

Permalink
Make it work correctly even when used with “BlazorWasmBrotliLoader.Bu…
Browse files Browse the repository at this point in the history
…ild” NuGet package.
  • Loading branch information
jsakamoto committed Sep 21, 2024
1 parent 5835c17 commit 4e21496
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 8 deletions.
33 changes: 31 additions & 2 deletions BlazorWasmPreRendering.Build.Test/ProgramE2ETest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,40 @@ public async Task Publish_Test()
serviceWorkerAssetsJs = Regex.Replace(serviceWorkerAssetsJs, ";\\s*$", "");
var assetsManifestFile = JsonSerializer.Deserialize<AssetsManifestFile>(serviceWorkerAssetsJs);
var assetManifestEntry = assetsManifestFile?.assets?.First(a => a.url == "index.html");
assetManifestEntry.IsNotNull();
assetManifestEntry!.hash.Is(hash);
assetManifestEntry.IsNotNull().hash.Is(hash);
}
}

[Test]
public async Task Publish_with_Compression_Test()
{
// Given
using var sampleAppWorkDir = SampleSite.CreateSampleAppsWorkDir();
var projectDir = Path.Combine(sampleAppWorkDir, "BlazorWasmApp0");

// When
var dotnetCLI = await Start("dotnet", "publish -c:Release -o:bin/publish", projectDir).WaitForExitAsync();
dotnetCLI.ExitCode.Is(0, message: dotnetCLI.Output);

// Then

// Validate prerendered contents.
var wwwrootDir = Path.Combine(projectDir, "bin", "publish", "wwwroot");
ValidatePrerenderedContentsOfApp0(wwwrootDir);

// Validate PWA assets manifest.
var indexHtmlBytes = File.ReadAllBytes(Path.Combine(wwwrootDir, "index.html"));
using var sha256 = SHA256.Create();
var hash = "sha256-" + Convert.ToBase64String(sha256.ComputeHash(indexHtmlBytes));

var serviceWorkerAssetsJs = File.ReadAllText(Path.Combine(wwwrootDir, "my-assets.js"));
serviceWorkerAssetsJs = Regex.Replace(serviceWorkerAssetsJs, @"^self\.assetsManifest\s*=\s*", "");
serviceWorkerAssetsJs = Regex.Replace(serviceWorkerAssetsJs, ";\\s*$", "");
var assetsManifestFile = JsonSerializer.Deserialize<AssetsManifestFile>(serviceWorkerAssetsJs);
var assetManifestEntry = assetsManifestFile?.assets?.First(a => a.url == "index.html");
assetManifestEntry.IsNotNull().hash.Is(hash);
}

[Test, Platform("Win")]
public async Task Publish_by_native_msbuild_Test()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<Import Project="Microsoft.AspNetCore.StaticWebAssets.props" />
<PropertyGroup>
<BeforePublishSPAforGHPages>$(BeforePublishSPAforGHPages);BlazorWasmPrerendering</BeforePublishSPAforGHPages>
<BeforeBlazorWasmBrotliLoader>$(BeforeBlazorWasmBrotliLoader);BlazorWasmPrerendering</BeforeBlazorWasmBrotliLoader>
</PropertyGroup>
</Project>
3 changes: 3 additions & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v.4.0.1
- Improve: Make it work correctly even when used with �gBlazorWasmBrotliLoader.Build�h NuGet package.

v.4.0.0
- This is the first official - not a preview - release.
- Breaking Change: Drop the support for .NET 5.
Expand Down
2 changes: 1 addition & 1 deletion SampleApps/BlazorWasmAVP/BlazorWasmAVP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.18" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.18" PrivateAssets="all" />
<PackageReference Include="BlazorWasmAntivirusProtection" Version="2.4.5" />
<PackageReference Include="BlazorWasmPreRendering.Build" Version="4.0.0" />
<PackageReference Include="BlazorWasmPreRendering.Build" Version="4.0.1-preview.1" />
</ItemGroup>

</Project>
3 changes: 2 additions & 1 deletion SampleApps/BlazorWasmApp0/BlazorWasmApp0.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BlazorWasmPreRendering.Build" Version="4.0.0" />
<PackageReference Include="BlazorWasmPreRendering.Build" Version="4.0.1-preview.1" />
<PackageReference Include="BlazorWasmBrotliLoader.Build" Version="1.0.0-preview.1" />
<PackageReference Include="PublishSPAforGitHubPages.Build" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.4" PrivateAssets="all" />
Expand Down
4 changes: 2 additions & 2 deletions SampleApps/BlazorWasmApp1/BlazorWasmApp1.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BlazorWasmPreRendering.Build" Version="4.0.0" />
<PackageReference Include="PublishSPAforGitHubPages.Build" Version="2.1.1" />
<PackageReference Include="BlazorWasmPreRendering.Build" Version="4.0.1-preview.1" />
<PackageReference Include="PublishSPAforGitHubPages.Build" Version="3.0.0-preview.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.4" PrivateAssets="all" />
<PackageReference Include="Toolbelt.Blazor.HeadElement" Version="7.3.1" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
Expand Down
1 change: 1 addition & 0 deletions SampleApps/SAMPLE-APPS-README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
|PWA | ✅ Yes | - | -
|Has easter-egg | - | ✅ Yes | -
|Deploy to GitHub Pages| - | ✅ Yes | -
|Brotli Loader | ✅ Yes | - | -
|Has AngleSharp dependency| ✅Yes | - | -
|Localization | ✅ Yes | - | -
|Lazy Load Assembly | ✅ Yes | ✅ Yes | -
Expand Down
2 changes: 1 addition & 1 deletion VersionInfo.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>4.0.0</Version>
<Version>4.0.1-preview.1</Version>
<Authors>J.Sakamoto</Authors>
<Copyright>Copyright © 2021-2024 J.Sakamoto, Mozilla Public License 2.0</Copyright>
<Description>When you publish your Blazor Wasm app, this package pre-renders and saves the app as static HTML files in your public folder.</Description>
Expand Down

0 comments on commit 4e21496

Please sign in to comment.