Browse Source

Exclude bootstrap from `global.js/css`.

pull/18876/head
maliming 3 years ago
parent
commit
06cf76a35a
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 17
      framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor.Theming/ComponentsComponentsBundleContributor.cs
  2. 10
      framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Bundling/AbpScripts.razor
  3. 10
      framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Bundling/AbpStyles.razor
  4. 17
      framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/ComponentsComponentsBundleContributor.cs
  5. 2
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/BundleConfig.cs
  6. 31
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/BundlingService.cs
  7. 10
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs
  8. 1
      framework/src/Volo.Abp.Core/Volo/Abp/Bundling/BundleContext.cs
  9. 1
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.WebApp.Client/wwwroot/appsettings.json
  10. 24
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.WebApp.Client/wwwroot/global.css
  11. 29
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.WebApp.Client/wwwroot/global.js
  12. 1
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.WebApp.Tiered.Client/wwwroot/appsettings.json
  13. 24
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.WebApp.Tiered.Client/wwwroot/global.css
  14. 29
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.WebApp.Tiered.Client/wwwroot/global.js
  15. 1
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.WebApp.Tiered/Components/App.razor
  16. 1
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.WebApp/Components/App.razor

17
framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor.Theming/ComponentsComponentsBundleContributor.cs

@ -12,14 +12,17 @@ public class ComponentsComponentsBundleContributor : IBundleContributor
public void AddStyles(BundleContext context) public void AddStyles(BundleContext context)
{ {
context.BundleDefinitions.Insert(0, new BundleDefinition if (!context.InteractiveAuto)
{ {
Source = "_content/Volo.Abp.AspNetCore.Components.MauiBlazor.Theming/libs/bootstrap/css/bootstrap.min.css" context.BundleDefinitions.Insert(0, new BundleDefinition
}); {
context.BundleDefinitions.Insert(1, new BundleDefinition Source = "_content/Volo.Abp.AspNetCore.Components.MauiBlazor.Theming/libs/bootstrap/css/bootstrap.min.css"
{ });
Source = "_content/Volo.Abp.AspNetCore.Components.MauiBlazor.Theming/libs/fontawesome/css/all.css" context.BundleDefinitions.Insert(1, new BundleDefinition
}); {
Source = "_content/Volo.Abp.AspNetCore.Components.MauiBlazor.Theming/libs/fontawesome/css/all.css"
});
}
context.Add("_content/Volo.Abp.AspNetCore.Components.MauiBlazor.Theming/libs/flag-icon/css/flag-icon.css"); context.Add("_content/Volo.Abp.AspNetCore.Components.MauiBlazor.Theming/libs/flag-icon/css/flag-icon.css");
context.Add("_content/Blazorise/blazorise.css"); context.Add("_content/Blazorise/blazorise.css");

10
framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Bundling/AbpScripts.razor

@ -20,16 +20,14 @@
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
if (OperatingSystem.IsBrowser() && WebAssemblyScriptFiles != null)
{
ScriptFiles = WebAssemblyScriptFiles;
return;
}
if (BundleName == null) if (BundleName == null)
{ {
throw new AbpException("The BundleName parameter of the AbpScripts component can not be null!"); throw new AbpException("The BundleName parameter of the AbpScripts component can not be null!");
} }
ScriptFiles = (await BundleManager.GetScriptBundleFilesAsync(BundleName!)).ToList(); ScriptFiles = (await BundleManager.GetScriptBundleFilesAsync(BundleName!)).ToList();
if (OperatingSystem.IsBrowser() && WebAssemblyScriptFiles != null)
{
ScriptFiles.AddRange(WebAssemblyScriptFiles);
}
} }
} }

10
framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Bundling/AbpStyles.razor

@ -20,16 +20,14 @@
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
if (OperatingSystem.IsBrowser() && WebAssemblyStyleFiles != null)
{
StyleFiles = WebAssemblyStyleFiles;
return;
}
if (BundleName == null) if (BundleName == null)
{ {
throw new AbpException("The BundleName parameter of the AbpStyles component can not be null!"); throw new AbpException("The BundleName parameter of the AbpStyles component can not be null!");
} }
StyleFiles = (await BundleManager.GetStyleBundleFilesAsync(BundleName!)).ToList(); StyleFiles = (await BundleManager.GetStyleBundleFilesAsync(BundleName!)).ToList();
if (OperatingSystem.IsBrowser() && WebAssemblyStyleFiles != null)
{
StyleFiles.AddRange(WebAssemblyStyleFiles);
}
} }
} }

17
framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/ComponentsComponentsBundleContributor.cs

@ -13,14 +13,17 @@ public class ComponentsComponentsBundleContributor : IBundleContributor
public void AddStyles(BundleContext context) public void AddStyles(BundleContext context)
{ {
context.BundleDefinitions.Insert(0, new BundleDefinition if (!context.InteractiveAuto)
{ {
Source = "_content/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/libs/bootstrap/css/bootstrap.min.css" context.BundleDefinitions.Insert(0, new BundleDefinition
}); {
context.BundleDefinitions.Insert(1, new BundleDefinition Source = "_content/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/libs/bootstrap/css/bootstrap.min.css"
{ });
Source = "_content/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/libs/fontawesome/css/all.css" context.BundleDefinitions.Insert(1, new BundleDefinition
}); {
Source = "_content/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/libs/fontawesome/css/all.css"
});
}
context.Add("_content/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/libs/flag-icon/css/flag-icon.css"); context.Add("_content/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/libs/flag-icon/css/flag-icon.css");
context.Add("_content/Blazorise/blazorise.css"); context.Add("_content/Blazorise/blazorise.css");

2
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/BundleConfig.cs

@ -6,6 +6,8 @@ public class BundleConfig
{ {
public bool IsBlazorWebApp { get; set; } = false; public bool IsBlazorWebApp { get; set; } = false;
public bool InteractiveAuto { get; set; } = false;
public BundlingMode Mode { get; set; } = BundlingMode.BundleAndMinify; public BundlingMode Mode { get; set; } = BundlingMode.BundleAndMinify;
public string Name { get; set; } = "global"; public string Name { get; set; } = "global";

31
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/BundlingService.cs

@ -104,27 +104,31 @@ public class BundlingService : IBundlingService, ITransientDependency
scriptDefinitions = GenerateScriptDefinitions(scriptContext); scriptDefinitions = GenerateScriptDefinitions(scriptContext);
} }
string fileName; if (!bundleConfig.InteractiveAuto)
if (bundleConfig.IsBlazorWebApp)
{ {
var projectDirectory = Path.GetDirectoryName(directory); string fileName;
fileName = Directory.GetFiles(projectDirectory!, "App.razor", SearchOption.AllDirectories).FirstOrDefault(); if (bundleConfig.IsBlazorWebApp)
} {
else var projectDirectory = Path.GetDirectoryName(directory);
{ fileName = Directory.GetFiles(projectDirectory!, "App.razor", SearchOption.AllDirectories).FirstOrDefault();
fileName = Path.Combine(PathHelper.GetWwwRootPath(directory), "index.html"); }
} else
{
fileName = Path.Combine(PathHelper.GetWwwRootPath(directory), "index.html");
}
await UpdateDependenciesInBlazorFileAsync(fileName, styleDefinitions, scriptDefinitions); await UpdateDependenciesInBlazorFileAsync(fileName, styleDefinitions, scriptDefinitions);
Logger.LogInformation($"Script and style references in the {fileName} file have been updated."); Logger.LogInformation($"Script and style references in the {fileName} file have been updated.");
}
} }
private BundleContext GetScriptContext(List<BundleTypeDefinition> bundleDefinitions, BundleConfig bundleConfig, string projectType) private BundleContext GetScriptContext(List<BundleTypeDefinition> bundleDefinitions, BundleConfig bundleConfig, string projectType)
{ {
var scriptContext = new BundleContext var scriptContext = new BundleContext
{ {
Parameters = bundleConfig.Parameters Parameters = bundleConfig.Parameters,
InteractiveAuto = bundleConfig.InteractiveAuto
}; };
if (projectType == BundlingConsts.WebAssembly && !bundleConfig.IsBlazorWebApp) if (projectType == BundlingConsts.WebAssembly && !bundleConfig.IsBlazorWebApp)
@ -147,7 +151,8 @@ public class BundlingService : IBundlingService, ITransientDependency
{ {
var styleContext = new BundleContext var styleContext = new BundleContext
{ {
Parameters = bundleConfig.Parameters Parameters = bundleConfig.Parameters,
InteractiveAuto = bundleConfig.InteractiveAuto
}; };
foreach (var bundleDefinition in bundleDefinitions) foreach (var bundleDefinition in bundleDefinitions)

10
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs

@ -155,16 +155,10 @@ public class AbpIoSourceCodeStore : ISourceCodeStore, ITransientDependency
throw new Exception("There is no version found with given version: " + version); throw new Exception("There is no version found with given version: " + version);
} }
var nugetVersion = await GetTemplateNugetVersionAsync(name, type, version) ?? version; var nugetVersion = version;
if (!string.IsNullOrWhiteSpace(templateSource) && !IsNetworkSource(templateSource))
{
Logger.LogInformation("Using local " + type + ": " + name + ", version: " + version);
return new TemplateFile(File.ReadAllBytes(Path.Combine(templateSource, name + "-" + version + ".zip")),
version, latestVersion, nugetVersion);
}
var localCacheFile = Path.Combine(CliPaths.TemplateCache, name.Replace("/", ".") + "-" + version + ".zip"); var localCacheFile = Path.Combine(CliPaths.TemplateCache, name.Replace("/", ".") + ".zip");
#if DEBUG #if DEBUG
if (File.Exists(localCacheFile)) if (File.Exists(localCacheFile))

1
framework/src/Volo.Abp.Core/Volo/Abp/Bundling/BundleContext.cs

@ -6,6 +6,7 @@ public class BundleContext
{ {
public List<BundleDefinition> BundleDefinitions { get; set; } public List<BundleDefinition> BundleDefinitions { get; set; }
public BundleParameterDictionary Parameters { get; set; } public BundleParameterDictionary Parameters { get; set; }
public bool InteractiveAuto { get; set; }
public BundleContext() public BundleContext()
{ {

1
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.WebApp.Client/wwwroot/appsettings.json

@ -9,6 +9,7 @@
"Mode": "BundleAndMinify", /* Options: None, Bundle, BundleAndMinify */ "Mode": "BundleAndMinify", /* Options: None, Bundle, BundleAndMinify */
"Name": "global", "Name": "global",
"IsBlazorWebApp": true, "IsBlazorWebApp": true,
"InteractiveAuto": true,
"Parameters": { "Parameters": {
} }

24
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.WebApp.Client/wwwroot/global.css

File diff suppressed because one or more lines are too long

29
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.WebApp.Client/wwwroot/global.js

File diff suppressed because one or more lines are too long

1
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.WebApp.Tiered.Client/wwwroot/appsettings.json

@ -9,6 +9,7 @@
"Mode": "BundleAndMinify", /* Options: None, Bundle, BundleAndMinify */ "Mode": "BundleAndMinify", /* Options: None, Bundle, BundleAndMinify */
"Name": "global", "Name": "global",
"IsBlazorWebApp": true, "IsBlazorWebApp": true,
"InteractiveAuto": true,
"Parameters": { "Parameters": {
} }

24
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.WebApp.Tiered.Client/wwwroot/global.css

File diff suppressed because one or more lines are too long

29
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.WebApp.Tiered.Client/wwwroot/global.js

File diff suppressed because one or more lines are too long

1
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.WebApp.Tiered/Components/App.razor

@ -59,7 +59,6 @@
private List<string> GlobalScripts => private List<string> GlobalScripts =>
[ [
"global.js",
"global.js" "global.js"
]; ];

1
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.WebApp/Components/App.razor

@ -55,7 +55,6 @@
private List<string> GlobalScripts => private List<string> GlobalScripts =>
[ [
"global.js",
"global.js" "global.js"
]; ];
} }

Loading…
Cancel
Save