Serve blazor.js in standalone site
This commit is contained in:
parent
a63b695db8
commit
e2a7d4fa40
|
|
@ -6,5 +6,6 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Hello</h1>
|
<h1>Hello</h1>
|
||||||
|
<script src="/_framework/blazor.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using Microsoft.Extensions.FileProviders;
|
||||||
|
using Microsoft.Extensions.Primitives;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Microsoft.Blazor.Browser
|
||||||
|
{
|
||||||
|
public class BlazorBrowserFileProvider : IFileProvider
|
||||||
|
{
|
||||||
|
private EmbeddedFileProvider _embeddedFiles = new EmbeddedFileProvider(
|
||||||
|
typeof(BlazorBrowserFileProvider).Assembly,
|
||||||
|
"blazor");
|
||||||
|
|
||||||
|
public IFileInfo GetFileInfo(string subpath)
|
||||||
|
=>_embeddedFiles.GetFileInfo(subpath.Replace('/', '$'));
|
||||||
|
|
||||||
|
public IDirectoryContents GetDirectoryContents(string subpath)
|
||||||
|
=> throw new NotImplementedException(); // Don't need to support this
|
||||||
|
|
||||||
|
public IChangeToken Watch(string filter)
|
||||||
|
=> throw new NotImplementedException(); // Don't need to support this
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -7,11 +7,15 @@
|
||||||
<DefaultItemExcludes>${DefaultItemExcludes};node_modules\**</DefaultItemExcludes>
|
<DefaultItemExcludes>${DefaultItemExcludes};node_modules\**</DefaultItemExcludes>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="2.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="RunWebpack" BeforeTargets="PreBuildEvent">
|
<Target Name="RunWebpack" BeforeTargets="PreBuildEvent">
|
||||||
<RemoveDir Directories="dist" />
|
<RemoveDir Directories="dist" />
|
||||||
<Exec Command="npm run build" WorkingDirectory="$(MSBuildThisFileDirectory)" />
|
<Exec Command="npm run build" WorkingDirectory="$(MSBuildThisFileDirectory)" />
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="dist/blazor.js" LogicalName="blazor.js" />
|
<EmbeddedResource Include="dist/blazor.js" LogicalName="blazor.$blazor.js" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Target>
|
</Target>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1 @@
|
||||||
const abc: string = "Hello";
|
console.log('Blazor is loading');
|
||||||
alert(abc);
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,9 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using Microsoft.AspNetCore.StaticFiles;
|
using Microsoft.AspNetCore.StaticFiles;
|
||||||
|
using Microsoft.Blazor.Browser;
|
||||||
using Microsoft.Blazor.Mono;
|
using Microsoft.Blazor.Mono;
|
||||||
|
using Microsoft.Extensions.FileProviders;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net.Mime;
|
using System.Net.Mime;
|
||||||
|
|
||||||
|
|
@ -15,7 +17,9 @@ namespace Microsoft.AspNetCore.Builder
|
||||||
applicationBuilder.UseStaticFiles(new StaticFileOptions
|
applicationBuilder.UseStaticFiles(new StaticFileOptions
|
||||||
{
|
{
|
||||||
RequestPath = "/_framework",
|
RequestPath = "/_framework",
|
||||||
FileProvider = new MonoStaticFileProvider(),
|
FileProvider = new CompositeFileProvider(
|
||||||
|
new MonoStaticFileProvider(),
|
||||||
|
new BlazorBrowserFileProvider()),
|
||||||
ContentTypeProvider = CreateContentTypeProvider(),
|
ContentTypeProvider = CreateContentTypeProvider(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,11 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.1" />
|
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.1" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.FileProviders.Composite" Version="2.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Microsoft.Blazor.Browser\Microsoft.Blazor.Browser.csproj" />
|
||||||
<ProjectReference Include="..\Microsoft.Blazor.Mono\Microsoft.Blazor.Mono.csproj" />
|
<ProjectReference Include="..\Microsoft.Blazor.Mono\Microsoft.Blazor.Mono.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue