diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling.Abstractions/Volo/Abp/AspNetCore/Mvc/UI/Bundling/AbpBundlingOptions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling.Abstractions/Volo/Abp/AspNetCore/Mvc/UI/Bundling/AbpBundlingOptions.cs index bc0fbcb3d2..de941c7537 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling.Abstractions/Volo/Abp/AspNetCore/Mvc/UI/Bundling/AbpBundlingOptions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling.Abstractions/Volo/Abp/AspNetCore/Mvc/UI/Bundling/AbpBundlingOptions.cs @@ -1,12 +1,14 @@ +using System.Collections.Generic; + namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling { public class AbpBundlingOptions { - public BundleConfigurationCollection StyleBundles { get; set; } + public BundleConfigurationCollection StyleBundles { get; } - public BundleConfigurationCollection ScriptBundles { get; set; } + public BundleConfigurationCollection ScriptBundles { get; } - //TODO: Add option to enable/disable bundling / minification + public HashSet MinificationIgnoredFiles { get; } /// /// Default: "__bundles". @@ -22,6 +24,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling { StyleBundles = new BundleConfigurationCollection(); ScriptBundles = new BundleConfigurationCollection(); + MinificationIgnoredFiles = new HashSet(); } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundlerBase.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundlerBase.cs index 0ddd40b1b9..9de47bba1f 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundlerBase.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundlerBase.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Options; using Volo.Abp.AspNetCore.VirtualFileSystem; using Volo.Abp.DependencyInjection; using Volo.Abp.Minify; @@ -18,11 +19,16 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling protected IWebHostEnvironment HostEnvironment { get; } protected IMinifier Minifier { get; } + protected AbpBundlingOptions BundlingOptions { get; } - protected BundlerBase(IWebHostEnvironment hostEnvironment, IMinifier minifier) + protected BundlerBase( + IWebHostEnvironment hostEnvironment, + IMinifier minifier, + IOptions bundlingOptions) { HostEnvironment = hostEnvironment; Minifier = minifier; + BundlingOptions = bundlingOptions.Value; Logger = NullLogger.Instance; } @@ -56,14 +62,22 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling private string GetFileContentConsideringMinification(IBundlerContext context, string fileName) { + var isIgnoredForMinification = BundlingOptions.MinificationIgnoredFiles.Contains(fileName); var isMinFile = IsMinFile(fileName); - if (!context.IsMinificationEnabled || isMinFile) + if (!context.IsMinificationEnabled || isIgnoredForMinification || isMinFile) { var fileContent = GetFileInfo(context, fileName).ReadAsString(); Logger.LogDebug($"- {fileName} ({fileContent.Length} bytes)"); - if (context.IsMinificationEnabled && isMinFile) + if (context.IsMinificationEnabled) { - Logger.LogDebug(" > Already minified"); + if (isMinFile) + { + Logger.LogDebug(" > Already minified."); + } + else if (isIgnoredForMinification) + { + Logger.LogDebug(" > Ignored for minification."); + } } return fileContent; diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/Scripts/ScriptBundler.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/Scripts/ScriptBundler.cs index 2065ac5aae..abcb3c3e0f 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/Scripts/ScriptBundler.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/Scripts/ScriptBundler.cs @@ -1,5 +1,6 @@ using System; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Options; using Volo.Abp.AspNetCore.VirtualFileSystem; using Volo.Abp.Minify.Scripts; @@ -9,8 +10,14 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.Scripts { public override string FileExtension => "js"; - public ScriptBundler(IWebHostEnvironment hostEnvironment, IJavascriptMinifier minifier) - : base(hostEnvironment, minifier) + public ScriptBundler( + IWebHostEnvironment hostEnvironment, + IJavascriptMinifier minifier, + IOptions bundlingOptions) + : base( + hostEnvironment, + minifier, + bundlingOptions) { } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/Styles/StyleBundler.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/Styles/StyleBundler.cs index 26dbb6aabb..ab5032ed2a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/Styles/StyleBundler.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/Styles/StyleBundler.cs @@ -1,6 +1,7 @@ using System; using System.IO; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Options; using Volo.Abp.AspNetCore.VirtualFileSystem; using Volo.Abp.Minify.Styles; @@ -11,8 +12,14 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.Styles private readonly IWebHostEnvironment _hostingEnvironment; public override string FileExtension => "css"; - public StyleBundler(IWebHostEnvironment hostEnvironment, ICssMinifier minifier) - : base(hostEnvironment, minifier) + public StyleBundler( + IWebHostEnvironment hostEnvironment, + ICssMinifier minifier, + IOptions bundlingOptions) + : base( + hostEnvironment, + minifier, + bundlingOptions) { _hostingEnvironment = hostEnvironment; } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpTagHelperResourceService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpTagHelperResourceService.cs index 87c0b7c077..4166a15c4f 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpTagHelperResourceService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpTagHelperResourceService.cs @@ -20,7 +20,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers public ILogger Logger { get; set; } protected IBundleManager BundleManager { get; } protected IWebHostEnvironment HostingEnvironment { get; } - protected readonly AbpBundlingOptions Options; + protected AbpBundlingOptions Options { get; } protected AbpTagHelperResourceService( IBundleManager bundleManager,