Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Remove WebMarkupMin

support1147c9784d43
diff --git a/src/Core/Grand.Infrastructure/Configuration/PerformanceConfig.cs b/src/Core/Grand.Infrastructure/Configuration/PerformanceConfig.cs
index 47321d5a6..367fdcbec 100644
--- a/src/Core/Grand.Infrastructure/Configuration/PerformanceConfig.cs
+++ b/src/Core/Grand.Infrastructure/Configuration/PerformanceConfig.cs
@@ -15,12 +15,6 @@ namespace Grand.Infrastructure.Configuration
/// </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>
diff --git a/src/Web/Grand.Web.Common/Grand.Web.Common.csproj b/src/Web/Grand.Web.Common/Grand.Web.Common.csproj
index 4614d203d..bdd47ee81 100644
--- a/src/Web/Grand.Web.Common/Grand.Web.Common.csproj
+++ b/src/Web/Grand.Web.Common/Grand.Web.Common.csproj
@@ -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>
diff --git a/src/Web/Grand.Web.Common/Infrastructure/ApplicationBuilderExtensions.cs b/src/Web/Grand.Web.Common/Infrastructure/ApplicationBuilderExtensions.cs
index fd974c7fb..d44130ca4 100644
--- a/src/Web/Grand.Web.Common/Infrastructure/ApplicationBuilderExtensions.cs
+++ b/src/Web/Grand.Web.Common/Infrastructure/ApplicationBuilderExtensions.cs
@@ -21,7 +21,6 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Hosting;
using Microsoft.Net.Http.Headers;
-using WebMarkupMin.AspNetCore6;
namespace Grand.Web.Common.Infrastructure
{
@@ -341,16 +340,7 @@ namespace Grand.Web.Common.Infrastructure
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>
diff --git a/src/Web/Grand.Web.Common/Infrastructure/ServiceCollectionExtensions.cs b/src/Web/Grand.Web.Common/Infrastructure/ServiceCollectionExtensions.cs
index 4e9eede27..d268ff7f4 100644
--- a/src/Web/Grand.Web.Common/Infrastructure/ServiceCollectionExtensions.cs
+++ b/src/Web/Grand.Web.Common/Infrastructure/ServiceCollectionExtensions.cs
@@ -23,15 +23,8 @@ using Microsoft.Extensions.Diagnostics.HealthChecks;
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
{
@@ -324,61 +317,6 @@ namespace Grand.Web.Common.Infrastructure
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();
diff --git a/src/Web/Grand.Web.Common/Startup/GrandCommonStartup.cs b/src/Web/Grand.Web.Common/Startup/GrandCommonStartup.cs
index 3b55f6283..4c98a37b8 100644
--- a/src/Web/Grand.Web.Common/Startup/GrandCommonStartup.cs
+++ b/src/Web/Grand.Web.Common/Startup/GrandCommonStartup.cs
@@ -100,12 +100,6 @@ namespace Grand.Web.Common.Startup
//gzip by default
application.UseResponseCompression();
}
-
- //Add webMarkupMin
- if (performanceConfig.UseHtmlMinification)
- {
- application.UseHtmlMinification();
- }
//use static files feature
application.UseGrandStaticFiles(appConfig);
diff --git a/src/Web/Grand.Web.Common/Startup/GrandMvcStartup.cs b/src/Web/Grand.Web.Common/Startup/GrandMvcStartup.cs
index 9a7dc7a1e..c11bf0b7f 100644
--- a/src/Web/Grand.Web.Common/Startup/GrandMvcStartup.cs
+++ b/src/Web/Grand.Web.Common/Startup/GrandMvcStartup.cs
@@ -25,9 +25,6 @@ namespace Grand.Web.Common.Startup
//add miniprofiler
services.AddGrandMiniProfiler();
- //add WebMarkupMin
- services.AddHtmlMinification(configuration);
-
//add ApplicationInsights
services.AddApplicationInsights(configuration);
diff --git a/src/Web/Grand.Web/App_Data/appsettings.json b/src/Web/Grand.Web/App_Data/appsettings.json
index 4d07d945e..528581375 100644
--- a/src/Web/Grand.Web/App_Data/appsettings.json
+++ b/src/Web/Grand.Web/App_Data/appsettings.json
@@ -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,