Skip to content

Commit

Permalink
Try using WebAssemblyPrerendered mode
Browse files Browse the repository at this point in the history
  • Loading branch information
linkoid committed Sep 5, 2024
1 parent 34a32b9 commit 4be696e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 11 additions & 3 deletions YetAnother.Web/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@
using YetAnother.Web;

var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
if (!builder.RootComponents.Any())
{
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
}

builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
ConfigureServices(builder.Services, builder.HostEnvironment.BaseAddress);

await builder.Build().RunAsync();

static void ConfigureServices(IServiceCollection services, string baseAddress)
{
services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(baseAddress) });
}
4 changes: 4 additions & 0 deletions YetAnother.Web/YetAnother.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
<LangVersion>preview</LangVersion>
</PropertyGroup>

<PropertyGroup>
<BlazorWasmPrerenderingMode>WebAssemblyPrerendered</BlazorWasmPrerenderingMode>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.33" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.33" PrivateAssets="all" />
Expand Down

0 comments on commit 4be696e

Please sign in to comment.