|
|
@ -46,28 +46,33 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling |
|
|
|
|
|
|
|
|
private void AddFileToBundle(IBundlerContext context, StringBuilder bundleContentBuilder, string fileName) |
|
|
private void AddFileToBundle(IBundlerContext context, StringBuilder bundleContentBuilder, string fileName) |
|
|
{ |
|
|
{ |
|
|
|
|
|
string fileContent = null; |
|
|
|
|
|
|
|
|
if (context.IsMinificationEnabled && !IsMinFile(fileName)) |
|
|
if (context.IsMinificationEnabled && !IsMinFile(fileName)) |
|
|
{ |
|
|
{ |
|
|
var minFileInfo = GetMinFileInfoOrNull(fileName); |
|
|
var minFileInfo = GetMinFileInfoOrNull(fileName); |
|
|
if (minFileInfo != null) |
|
|
if (minFileInfo != null) |
|
|
{ |
|
|
{ |
|
|
Logger.LogDebug($"- {fileName} ({minFileInfo.Length} bytes)"); |
|
|
Logger.LogDebug($"- {fileName} ({minFileInfo.Length} bytes) - already minified"); |
|
|
bundleContentBuilder.Append(NormalizedCode(minFileInfo.ReadAsString())); |
|
|
fileContent = minFileInfo.ReadAsString(); |
|
|
return; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var fileContent = GetFileContent(context, fileName); |
|
|
if (fileContent == null) |
|
|
Logger.LogDebug($"- {fileName} ({fileContent.Length} bytes)"); |
|
|
|
|
|
|
|
|
|
|
|
if (context.IsMinificationEnabled) |
|
|
|
|
|
{ |
|
|
{ |
|
|
var nonMinifiedSize = fileContent.Length; |
|
|
fileContent = GetFileContent(context, fileName); |
|
|
fileContent = Minifier.Minify(fileContent, context.BundleRelativePath); |
|
|
Logger.LogDebug($"- {fileName} ({fileContent.Length} bytes) - non minified"); |
|
|
Logger.LogInformation($" -- Minified {context.BundleRelativePath} ({nonMinifiedSize} bytes -> {fileContent.Length} bytes)"); |
|
|
|
|
|
|
|
|
if (context.IsMinificationEnabled) |
|
|
|
|
|
{ |
|
|
|
|
|
var nonMinifiedSize = fileContent.Length; |
|
|
|
|
|
fileContent = Minifier.Minify(fileContent, context.BundleRelativePath); |
|
|
|
|
|
Logger.LogInformation($" > Minified {fileName} ({nonMinifiedSize} bytes -> {fileContent.Length} bytes)"); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bundleContentBuilder.Append(NormalizedCode(fileContent)); |
|
|
fileContent = ProcessBeforeAddingToTheBundle(context, fileName, fileContent); |
|
|
|
|
|
bundleContentBuilder.Append(fileContent); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected virtual string GetFileContent(IBundlerContext context, string file) |
|
|
protected virtual string GetFileContent(IBundlerContext context, string file) |
|
|
@ -99,9 +104,9 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling |
|
|
return fileInfo.Exists ? fileInfo : null; |
|
|
return fileInfo.Exists ? fileInfo : null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected virtual string NormalizedCode(string code) |
|
|
protected virtual string ProcessBeforeAddingToTheBundle(IBundlerContext context, string filePath, string fileContent) |
|
|
{ |
|
|
{ |
|
|
return code; |
|
|
return fileContent; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |