|
|
|
@ -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<AbpBundlingOptions> bundlingOptions) |
|
|
|
{ |
|
|
|
HostEnvironment = hostEnvironment; |
|
|
|
Minifier = minifier; |
|
|
|
BundlingOptions = bundlingOptions.Value; |
|
|
|
|
|
|
|
Logger = NullLogger<BundlerBase>.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; |
|
|
|
|