Browse Source

`IsBundlingEnabled`

pull/19968/head
maliming 2 years ago
parent
commit
ad9678e073
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 28
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/AbpAspNetCoreMvcUiBundlingModule.cs
  2. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleManager.cs

28
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; return;
} }
var bundleManager = context.ServiceProvider.GetRequiredService<IBundleManager>(); var bundleManager = context.ServiceProvider.GetRequiredService<BundleManager>();
var webHostEnvironment = context.ServiceProvider.GetRequiredService<IWebHostEnvironment>(); var webHostEnvironment = context.ServiceProvider.GetRequiredService<IWebHostEnvironment>();
var dynamicFileProvider = context.ServiceProvider.GetRequiredService<IDynamicFileProvider>(); var dynamicFileProvider = context.ServiceProvider.GetRequiredService<IDynamicFileProvider>();
if (!bundlingOptions.GlobalAssets.GlobalStyleBundleName.IsNullOrWhiteSpace()) if (!bundlingOptions.GlobalAssets.GlobalStyleBundleName.IsNullOrWhiteSpace())
@ -64,12 +64,18 @@ public class AbpAspNetCoreMvcUiBundlingModule : AbpModule
} }
var fileContent = await fileInfo.ReadAsStringAsync(); var fileContent = await fileInfo.ReadAsStringAsync();
if (!bundleManager.IsBundlingEnabled())
{
fileContent = CssRelativePath.Adjust(fileContent,
file.FileName,
Path.Combine(Directory.GetCurrentDirectory(), "wwwroot"));
fileContent = CssRelativePath.Adjust(fileContent, styles += $"/*{file.FileName}*/{Environment.NewLine}{fileContent}{Environment.NewLine}{Environment.NewLine}";
file.FileName, }
Path.Combine(Directory.GetCurrentDirectory(), "wwwroot")); else
{
styles += $"/*{file.FileName}*/{Environment.NewLine}{fileContent}{Environment.NewLine}{Environment.NewLine}"; styles += $"{fileContent}{Environment.NewLine}{Environment.NewLine}";
}
} }
dynamicFileProvider.AddOrUpdate( dynamicFileProvider.AddOrUpdate(
@ -91,8 +97,14 @@ public class AbpAspNetCoreMvcUiBundlingModule : AbpModule
} }
var fileContent = await fileInfo.ReadAsStringAsync(); var fileContent = await fileInfo.ReadAsStringAsync();
if (!bundleManager.IsBundlingEnabled())
scripts += $"//{file.FileName}{Environment.NewLine}{fileContent.EnsureEndsWith(';')}{Environment.NewLine}{Environment.NewLine}"; {
scripts += $"{fileContent.EnsureEndsWith(';')}{Environment.NewLine}{Environment.NewLine}";
}
else
{
scripts += $"//{file.FileName}{Environment.NewLine}{fileContent.EnsureEndsWith(';')}{Environment.NewLine}{Environment.NewLine}";
}
} }
dynamicFileProvider.AddOrUpdate( dynamicFileProvider.AddOrUpdate(

2
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) switch (Options.Mode)
{ {

Loading…
Cancel
Save