Skip to content

Commit

Permalink
Remove WebMarkupMin
Browse files Browse the repository at this point in the history
  • Loading branch information
support committed Nov 18, 2023
1 parent 56c9744 commit 1147c97
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ public partial class PerformanceConfig
/// </summary>
public bool UseResponseCompression { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to enable html minification
/// </summary>
public bool UseHtmlMinification { get; set; }
public bool HtmlMinificationErrors { get; set; }

/// <summary>
/// Gets or sets a value indicating whether ignore InstallUrlMiddleware
/// </summary>
Expand Down
3 changes: 0 additions & 3 deletions src/Web/Grand.Web.Common/Grand.Web.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
<PackageReference Include="MiniProfiler.AspNetCore.Mvc" Version="4.3.8" />
<PackageReference Include="NetEscapades.AspNetCore.SecurityHeaders" Version="0.21.0" />
<PackageReference Include="Wangkanai.Detection" Version="7.4.0" />
<PackageReference Include="WebMarkupMin.AspNetCore6" Version="2.15.1" />
<PackageReference Include="WebMarkupMin.Core" Version="2.14.0" />
<PackageReference Include="WebMarkupMin.NUglify" Version="2.15.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.24" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Hosting;
using Microsoft.Net.Http.Headers;
using WebMarkupMin.AspNetCore6;

namespace Grand.Web.Common.Infrastructure
{
Expand Down Expand Up @@ -341,16 +340,7 @@ public static void UseDefaultSecurityHeaders(this IApplicationBuilder applicatio

application.UseSecurityHeaders(policyCollection);
}

/// <summary>
/// Use WebMarkupMin for your application.
/// </summary>
/// <param name="application">Builder for configuring an application's request pipeline</param>
public static void UseHtmlMinification(this IApplicationBuilder application)
{
application.UseWebMarkupMin();
}


/// <summary>
/// Configure middleware checking whether database is installed
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,8 @@
using Microsoft.Extensions.WebEncoders;
using Newtonsoft.Json.Serialization;
using StackExchange.Redis;
using System.IO.Compression;
using System.Text.Encodings.Web;
using System.Text.Unicode;
using WebMarkupMin.AspNet.Common.Compressors;
using WebMarkupMin.AspNet.Common.UrlMatchers;
using WebMarkupMin.AspNetCore6;
using WebMarkupMin.NUglify;
using IWmmLogger = WebMarkupMin.Core.Loggers.ILogger;
using WmmThrowExceptionLogger = WebMarkupMin.Core.Loggers.ThrowExceptionLogger;

namespace Grand.Web.Common.Infrastructure
{
Expand Down Expand Up @@ -324,61 +317,6 @@ public static void AddGrandHealthChecks(this IServiceCollection services)
tags: new[] { "mongodb" });
}

public static void AddHtmlMinification(this IServiceCollection services, IConfiguration configuration)
{
var performanceConfig = new PerformanceConfig();
configuration.GetSection("Performance").Bind(performanceConfig);
if (performanceConfig.UseHtmlMinification)
{
// Add WebMarkupMin services
services.AddWebMarkupMin(options =>
{
options.AllowMinificationInDevelopmentEnvironment = true;
options.AllowCompressionInDevelopmentEnvironment = true;
})
.AddHtmlMinification(options =>
{
options.MinificationSettings.RemoveOptionalEndTags = false;
options.ExcludedPages = new List<IUrlMatcher> {
new WildcardUrlMatcher("/swagger/*"),
new WildcardUrlMatcher("/admin/*"),
new ExactUrlMatcher("/admin")
};
options.CssMinifierFactory = new NUglifyCssMinifierFactory();
options.JsMinifierFactory = new NUglifyJsMinifierFactory();
})
.AddXmlMinification(options =>
{
options.ExcludedPages = new List<IUrlMatcher> {
new WildcardUrlMatcher("/swagger/*"),
new WildcardUrlMatcher("/admin/*"),
new ExactUrlMatcher("/admin")
};
})
.AddHttpCompression(options =>
{
options.ExcludedPages = new List<IUrlMatcher> {
new WildcardUrlMatcher("/swagger/*")
};
options.CompressorFactories = new List<ICompressorFactory> {
new BuiltInBrotliCompressorFactory(new BuiltInBrotliCompressionSettings {
Level = CompressionLevel.Fastest
}),
new DeflateCompressorFactory(new DeflateCompressionSettings {
Level = CompressionLevel.Fastest
}),
new GZipCompressorFactory(new GZipCompressionSettings {
Level = CompressionLevel.Fastest
})
};
});
}

if (performanceConfig.HtmlMinificationErrors)
services.AddSingleton<IWmmLogger, WmmThrowExceptionLogger>();
}

public static void AddApplicationInsights(this IServiceCollection services, IConfiguration configuration)
{
var applicationInsights = new ApplicationInsightsConfig();
Expand Down
6 changes: 0 additions & 6 deletions src/Web/Grand.Web.Common/Startup/GrandCommonStartup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,6 @@ public void Configure(IApplicationBuilder application, IWebHostEnvironment webHo
//gzip by default
application.UseResponseCompression();
}

//Add webMarkupMin
if (performanceConfig.UseHtmlMinification)
{
application.UseHtmlMinification();
}

//use static files feature
application.UseGrandStaticFiles(appConfig);
Expand Down
3 changes: 0 additions & 3 deletions src/Web/Grand.Web.Common/Startup/GrandMvcStartup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
//add miniprofiler
services.AddGrandMiniProfiler();

//add WebMarkupMin
services.AddHtmlMinification(configuration);

//add ApplicationInsights
services.AddApplicationInsights(configuration);

Expand Down
4 changes: 0 additions & 4 deletions src/Web/Grand.Web/App_Data/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,6 @@
},
"Performance": {

//Flag for whether to enable html minification
"UseHtmlMinification": false,
"HtmlMinificationErrors": false,

//Indicates whether to compress response (gzip by default)
//You may want to disable it, for example, If you have an active IIS Dynamic Compression Module configured at the server level
"UseResponseCompression": false,
Expand Down

0 comments on commit 1147c97

Please sign in to comment.