From ad9678e073f079109f40e9c9ca0ddbac12d7237e Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 6 Jun 2024 16:33:19 +0800 Subject: [PATCH] `IsBundlingEnabled` --- .../AbpAspNetCoreMvcUiBundlingModule.cs | 28 +++++++++++++------ .../Mvc/UI/Bundling/BundleManager.cs | 2 +- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/AbpAspNetCoreMvcUiBundlingModule.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/AbpAspNetCoreMvcUiBundlingModule.cs index f1d5c75a76..72d3315233 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/AbpAspNetCoreMvcUiBundlingModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/AbpAspNetCoreMvcUiBundlingModule.cs @@ -47,7 +47,7 @@ public class AbpAspNetCoreMvcUiBundlingModule : AbpModule return; } - var bundleManager = context.ServiceProvider.GetRequiredService(); + var bundleManager = context.ServiceProvider.GetRequiredService(); var webHostEnvironment = context.ServiceProvider.GetRequiredService(); var dynamicFileProvider = context.ServiceProvider.GetRequiredService(); if (!bundlingOptions.GlobalAssets.GlobalStyleBundleName.IsNullOrWhiteSpace()) @@ -64,12 +64,18 @@ public class AbpAspNetCoreMvcUiBundlingModule : AbpModule } var fileContent = await fileInfo.ReadAsStringAsync(); + if (!bundleManager.IsBundlingEnabled()) + { + fileContent = CssRelativePath.Adjust(fileContent, + file.FileName, + Path.Combine(Directory.GetCurrentDirectory(), "wwwroot")); - fileContent = CssRelativePath.Adjust(fileContent, - file.FileName, - Path.Combine(Directory.GetCurrentDirectory(), "wwwroot")); - - styles += $"/*{file.FileName}*/{Environment.NewLine}{fileContent}{Environment.NewLine}{Environment.NewLine}"; + styles += $"/*{file.FileName}*/{Environment.NewLine}{fileContent}{Environment.NewLine}{Environment.NewLine}"; + } + else + { + styles += $"{fileContent}{Environment.NewLine}{Environment.NewLine}"; + } } dynamicFileProvider.AddOrUpdate( @@ -91,8 +97,14 @@ public class AbpAspNetCoreMvcUiBundlingModule : AbpModule } var fileContent = await fileInfo.ReadAsStringAsync(); - - scripts += $"//{file.FileName}{Environment.NewLine}{fileContent.EnsureEndsWith(';')}{Environment.NewLine}{Environment.NewLine}"; + if (!bundleManager.IsBundlingEnabled()) + { + scripts += $"{fileContent.EnsureEndsWith(';')}{Environment.NewLine}{Environment.NewLine}"; + } + else + { + scripts += $"//{file.FileName}{Environment.NewLine}{fileContent.EnsureEndsWith(';')}{Environment.NewLine}{Environment.NewLine}"; + } } dynamicFileProvider.AddOrUpdate( diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleManager.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleManager.cs index f1e87357f3..9ac43585c0 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleManager.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleManager.cs @@ -172,7 +172,7 @@ public class BundleManager : IBundleManager, ITransientDependency ); } - protected virtual bool IsBundlingEnabled() + public virtual bool IsBundlingEnabled() { switch (Options.Mode) {