Browse Source

Implemented blazor server side bundling.

pull/8074/head
Halil İbrahim Kalkan 6 years ago
parent
commit
4425ac2703
  1. 7
      framework/Volo.Abp.sln
  2. 6
      framework/src/Volo.Abp.AspNetCore.Components.Server.BasicTheme/AbpAspNetCoreComponentsServerBasicThemeModule.cs
  3. 1
      framework/src/Volo.Abp.AspNetCore.Components.Server.BasicTheme/Volo.Abp.AspNetCore.Components.Server.BasicTheme.csproj
  4. 36
      framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/AbpAspNetCoreComponentsServerThemingModule.cs
  5. 15
      framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/Bundling/BlazorGlobalBundles.cs
  6. 15
      framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/Bundling/BlazorGlobalScriptContributor.cs
  7. 23
      framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/Bundling/BlazorGlobalStyleContributor.cs
  8. 3
      framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/FodyWeavers.xml
  9. 30
      framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/FodyWeavers.xsd
  10. 18
      framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/Volo.Abp.AspNetCore.Components.Server.Theming.csproj
  11. 12
      framework/src/Volo.Abp.AspNetCore.Components.Server/Volo/Abp/AspNetCore/Components/Server/AbpAspNetCoreComponentsServerModule.cs
  12. 6
      nupkg/common.ps1
  13. 5
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyProjectNameBlazorServerModule.cs
  14. 28
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Pages/_Host.cshtml
  15. 4
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Pages/_ViewImports.cshtml
  16. 7
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/TestStyleBundleContributor.cs

7
framework/Volo.Abp.sln

@ -375,6 +375,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Sms.Aliyun.Tests",
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Components.Server", "src\Volo.Abp.AspNetCore.Components.Server\Volo.Abp.AspNetCore.Components.Server.csproj", "{863C18F9-2407-49F9-9ADC-F6229AF3B385}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Components.Server", "src\Volo.Abp.AspNetCore.Components.Server\Volo.Abp.AspNetCore.Components.Server.csproj", "{863C18F9-2407-49F9-9ADC-F6229AF3B385}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Components.Server.Theming", "src\Volo.Abp.AspNetCore.Components.Server.Theming\Volo.Abp.AspNetCore.Components.Server.Theming.csproj", "{B4B6B7DE-9798-4007-B1DF-7EE7929E392A}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -1117,6 +1119,10 @@ Global
{863C18F9-2407-49F9-9ADC-F6229AF3B385}.Debug|Any CPU.Build.0 = Debug|Any CPU {863C18F9-2407-49F9-9ADC-F6229AF3B385}.Debug|Any CPU.Build.0 = Debug|Any CPU
{863C18F9-2407-49F9-9ADC-F6229AF3B385}.Release|Any CPU.ActiveCfg = Release|Any CPU {863C18F9-2407-49F9-9ADC-F6229AF3B385}.Release|Any CPU.ActiveCfg = Release|Any CPU
{863C18F9-2407-49F9-9ADC-F6229AF3B385}.Release|Any CPU.Build.0 = Release|Any CPU {863C18F9-2407-49F9-9ADC-F6229AF3B385}.Release|Any CPU.Build.0 = Release|Any CPU
{B4B6B7DE-9798-4007-B1DF-7EE7929E392A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B4B6B7DE-9798-4007-B1DF-7EE7929E392A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B4B6B7DE-9798-4007-B1DF-7EE7929E392A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B4B6B7DE-9798-4007-B1DF-7EE7929E392A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -1306,6 +1312,7 @@ Global
{ACFBA3FB-18CE-4655-9D14-1F1F5C3DFC30} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {ACFBA3FB-18CE-4655-9D14-1F1F5C3DFC30} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6}
{DADEA538-3CA1-4ADE-A7E6-EF77A0CE4401} = {447C8A77-E5F0-4538-8687-7383196D04EA} {DADEA538-3CA1-4ADE-A7E6-EF77A0CE4401} = {447C8A77-E5F0-4538-8687-7383196D04EA}
{863C18F9-2407-49F9-9ADC-F6229AF3B385} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {863C18F9-2407-49F9-9ADC-F6229AF3B385} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6}
{B4B6B7DE-9798-4007-B1DF-7EE7929E392A} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5} SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5}

6
framework/src/Volo.Abp.AspNetCore.Components.Server.BasicTheme/AbpAspNetCoreComponentsServerBasicThemeModule.cs

@ -1,11 +1,13 @@
using Volo.Abp.AspNetCore.Components.Web.Theming.Routing; using Volo.Abp.AspNetCore.Components.Server.Theming;
using Volo.Abp.AspNetCore.Components.Web.Theming.Routing;
using Volo.Abp.AspNetCore.Components.Web.Theming.Toolbars; using Volo.Abp.AspNetCore.Components.Web.Theming.Toolbars;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
namespace Volo.Abp.AspNetCore.Components.Web.BasicTheme.Server namespace Volo.Abp.AspNetCore.Components.Web.BasicTheme.Server
{ {
[DependsOn( [DependsOn(
typeof(AbpAspNetCoreComponentsWebBasicThemeModule) typeof(AbpAspNetCoreComponentsWebBasicThemeModule),
typeof(AbpAspNetCoreComponentsServerThemingModule)
)] )]
public class AbpAspNetCoreComponentsServerBasicThemeModule : AbpModule public class AbpAspNetCoreComponentsServerBasicThemeModule : AbpModule
{ {

1
framework/src/Volo.Abp.AspNetCore.Components.Server.BasicTheme/Volo.Abp.AspNetCore.Components.Server.BasicTheme.csproj

@ -15,6 +15,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Volo.Abp.AspNetCore.Components.Server.Theming\Volo.Abp.AspNetCore.Components.Server.Theming.csproj" />
<ProjectReference Include="..\Volo.Abp.AspNetCore.Components.Web.BasicTheme\Volo.Abp.AspNetCore.Components.Web.BasicTheme.csproj" /> <ProjectReference Include="..\Volo.Abp.AspNetCore.Components.Web.BasicTheme\Volo.Abp.AspNetCore.Components.Web.BasicTheme.csproj" />
</ItemGroup> </ItemGroup>

36
framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/AbpAspNetCoreComponentsServerThemingModule.cs

@ -0,0 +1,36 @@
using Volo.Abp.AspNetCore.Components.Server.Theming.Bundling;
using Volo.Abp.AspNetCore.Components.Web.Theming;
using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
using Volo.Abp.AspNetCore.Mvc.UI.Packages;
using Volo.Abp.Modularity;
namespace Volo.Abp.AspNetCore.Components.Server.Theming
{
[DependsOn(
typeof(AbpAspNetCoreComponentsServerModule),
typeof(AbpAspNetCoreMvcUiPackagesModule),
typeof(AbpAspNetCoreComponentsWebThemingModule)
)]
public class AbpAspNetCoreComponentsServerThemingModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpBundlingOptions>(options =>
{
options
.StyleBundles
.Add(BlazorStandardBundles.Styles.Global, bundle =>
{
bundle.AddContributors(typeof(BlazorGlobalStyleContributor));
});
options
.ScriptBundles
.Add(BlazorStandardBundles.Scripts.Global, bundle =>
{
bundle.AddContributors(typeof(BlazorGlobalScriptContributor));
});
});
}
}
}

15
framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/Bundling/BlazorGlobalBundles.cs

@ -0,0 +1,15 @@
namespace Volo.Abp.AspNetCore.Components.Server.Theming.Bundling
{
public class BlazorStandardBundles
{
public static class Styles
{
public static string Global = "Blazor.Global";
}
public static class Scripts
{
public static string Global = "Blazor.Global";
}
}
}

15
framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/Bundling/BlazorGlobalScriptContributor.cs

@ -0,0 +1,15 @@
using System.Collections.Generic;
using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
namespace Volo.Abp.AspNetCore.Components.Server.Theming.Bundling
{
public class BlazorGlobalScriptContributor : BundleContributor
{
public override void ConfigureBundle(BundleConfigurationContext context)
{
context.Files.AddIfNotContains("/_framework/blazor.server.js");
context.Files.AddIfNotContains("/_content/Blazorise/blazorise.js");
context.Files.AddIfNotContains("/_content/Blazorise.Bootstrap/blazorise.bootstrap.js");
}
}
}

23
framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/Bundling/BlazorGlobalStyleContributor.cs

@ -0,0 +1,23 @@
using System.Collections.Generic;
using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
using Volo.Abp.AspNetCore.Mvc.UI.Packages.Bootstrap;
using Volo.Abp.AspNetCore.Mvc.UI.Packages.FontAwesome;
using Volo.Abp.Modularity;
namespace Volo.Abp.AspNetCore.Components.Server.Theming.Bundling
{
[DependsOn(
typeof(BootstrapStyleContributor),
typeof(FontAwesomeStyleContributor)
)]
public class BlazorGlobalStyleContributor : BundleContributor
{
public override void ConfigureBundle(BundleConfigurationContext context)
{
context.Files.AddIfNotContains("/_content/Blazorise/blazorise.css");
context.Files.AddIfNotContains("/_content/Blazorise.Bootstrap/blazorise.bootstrap.css");
context.Files.AddIfNotContains("/_content/Blazorise.Snackbar/blazorise.snackbar.css");
context.Files.AddIfNotContains("/_content/Volo.Abp.AspNetCore.Components.Web.BasicTheme/libs/abp/css/theme.css");
}
}
}

3
framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/FodyWeavers.xml

@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ConfigureAwait />
</Weavers>

30
framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/FodyWeavers.xsd

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" />
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>

18
framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/Volo.Abp.AspNetCore.Components.Server.Theming.csproj

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\..\configureawait.props" />
<Import Project="..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>true</IsPackable>
<OutputType>Library</OutputType>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Volo.Abp.AspNetCore.Components.Server\Volo.Abp.AspNetCore.Components.Server.csproj" />
<ProjectReference Include="..\Volo.Abp.AspNetCore.Components.Web.Theming\Volo.Abp.AspNetCore.Components.Web.Theming.csproj" />
<ProjectReference Include="..\Volo.Abp.AspNetCore.Mvc.UI.Packages\Volo.Abp.AspNetCore.Mvc.UI.Packages.csproj" />
</ItemGroup>
</Project>

12
framework/src/Volo.Abp.AspNetCore.Components.Server/Volo/Abp/AspNetCore/Components/Server/AbpAspNetCoreComponentsServerModule.cs

@ -1,4 +1,6 @@
using Volo.Abp.Modularity; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Volo.Abp.Modularity;
namespace Volo.Abp.AspNetCore.Components.Server namespace Volo.Abp.AspNetCore.Components.Server
{ {
@ -7,5 +9,13 @@ namespace Volo.Abp.AspNetCore.Components.Server
)] )]
public class AbpAspNetCoreComponentsServerModule : AbpModule public class AbpAspNetCoreComponentsServerModule : AbpModule
{ {
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
context.GetEnvironment().WebRootFileProvider =
new CompositeFileProvider(
new ManifestEmbeddedFileProvider(typeof(IServerSideBlazorBuilder).Assembly),
context.GetEnvironment().WebRootFileProvider
);
}
} }
} }

6
nupkg/common.ps1

@ -34,12 +34,14 @@ $projects = (
"framework/src/Volo.Abp.AspNetCore.Components", "framework/src/Volo.Abp.AspNetCore.Components",
"framework/src/Volo.Abp.AspNetCore.Components.Server", "framework/src/Volo.Abp.AspNetCore.Components.Server",
"framework/src/Volo.Abp.AspNetCore.Components.Web", "framework/src/Volo.Abp.AspNetCore.Components.Web",
"framework/src/Volo.Abp.AspNetCore.Components.Web.BasicTheme",
"framework/src/Volo.Abp.AspNetCore.Components.Web.BasicTheme.Server",
"framework/src/Volo.Abp.AspNetCore.Components.Web.Theming", "framework/src/Volo.Abp.AspNetCore.Components.Web.Theming",
"framework/src/Volo.Abp.AspNetCore.Components.Web.BasicTheme",
"framework/src/Volo.Abp.AspNetCore.Components.WebAssembly", "framework/src/Volo.Abp.AspNetCore.Components.WebAssembly",
"framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming", "framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming",
"framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme", "framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme",
"framework/src/Volo.Abp.AspNetCore.Components.Server",
"framework/src/Volo.Abp.AspNetCore.Components.Server.Theming",
"framework/src/Volo.Abp.AspNetCore.Components.Server.BasicTheme",
"framework/src/Volo.Abp.AspNetCore.MultiTenancy", "framework/src/Volo.Abp.AspNetCore.MultiTenancy",
"framework/src/Volo.Abp.AspNetCore.Mvc.Client", "framework/src/Volo.Abp.AspNetCore.Mvc.Client",
"framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common", "framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common",

5
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyProjectNameBlazorServerModule.cs

@ -27,6 +27,7 @@ using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Bundling;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
using Volo.Abp.AspNetCore.Serilog; using Volo.Abp.AspNetCore.Serilog;
using Volo.Abp.AspNetCore.VirtualFileSystem;
using Volo.Abp.Autofac; using Volo.Abp.Autofac;
using Volo.Abp.AutoMapper; using Volo.Abp.AutoMapper;
using Volo.Abp.Identity.Blazor; using Volo.Abp.Identity.Blazor;
@ -240,10 +241,8 @@ namespace MyCompanyName.MyProjectName.Blazor.Server
} }
app.UseHttpsRedirection(); app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCorrelationId(); app.UseCorrelationId();
app.UseVirtualFiles(); app.UseStaticFiles();
app.UseRouting(); app.UseRouting();
app.UseAuthentication(); app.UseAuthentication();
app.UseJwtTokenMiddleware(); app.UseJwtTokenMiddleware();

28
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Pages/_Host.cshtml

@ -1,7 +1,7 @@
@page "/" @page "/"
@namespace MyCompanyName.MyProjectName.Blazor.Server.Pages @namespace MyCompanyName.MyProjectName.Blazor.Server.Pages
@using Volo.Abp.AspNetCore.Components.Web.BasicTheme.Themes.Basic @using Volo.Abp.AspNetCore.Components.Web.BasicTheme.Themes.Basic
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @using Volo.Abp.AspNetCore.Components.Server.Theming.Bundling
@{ @{
Layout = null; Layout = null;
} }
@ -13,32 +13,12 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>MyCompanyName.MyProjectName.Blazor.Server</title> <title>MyCompanyName.MyProjectName.Blazor.Server</title>
<base href="~/" /> <base href="~/" />
<!--ABP:Styles--> <abp-style-bundle name="@BlazorStandardBundles.Styles.Global" />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.12.0/css/all.css">
<link href="_content/Blazorise/blazorise.css" rel="stylesheet" />
<link href="_content/Blazorise.Bootstrap/blazorise.bootstrap.css" rel="stylesheet" />
<link href="_content/Blazorise.Snackbar/blazorise.snackbar.css" rel="stylesheet" />
<link href="_content/Volo.Abp.AspNetCore.Components.UI.BasicTheme/libs/abp/css/theme.css" rel="stylesheet" />
<link href="css/site.css" rel="stylesheet" />
<!--/ABP:Styles-->
</head> </head>
<body> <body>
<component type="typeof(App)" render-mode="Server" /> <component type="typeof(App)" render-mode="Server" />
<!--ABP:Scripts--> <abp-script-bundle name="@BlazorStandardBundles.Scripts.Global" />
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
<script src="_content/Blazorise/blazorise.js"></script>
<script src="_content/Blazorise.Bootstrap/blazorise.bootstrap.js"></script>
<script src="_framework/blazor.server.js"></script>
<!--/ABP:Scripts-->
</body> </body>
</html> </html>

4
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Pages/_ViewImports.cshtml

@ -0,0 +1,4 @@
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bundling

7
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/TestStyleBundleContributor.cs

@ -0,0 +1,7 @@
namespace MyCompanyName.MyProjectName.Blazor.Server
{
public class TestStyleBundleContributor
{
}
}
Loading…
Cancel
Save