diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/BundleContributer.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/BundleContributer.cs index 90b45c2215..81ff6044b2 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/BundleContributer.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/BundleContributer.cs @@ -5,14 +5,22 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme { public class BundleContributer : IBundleContributer { - public void AddScripts(List scripts) + public void AddScripts(List scriptDefinitions) { } - public void AddStyles(List styles) + public void AddStyles(List styleDefinitions) { - styles.AddIfNotContains("_content/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/libs/abp/css/theme.css"); + var styles = new string[] + { + "_content/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/libs/abp/css/theme.css", + }; + + foreach (var style in styles) + { + styleDefinitions.AddIfNotContains((item) => item.Source == style, () => new BundleDefinition(style)); + } } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/BundleContributer.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/BundleContributer.cs index 0c8e70429f..fa46219c06 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/BundleContributer.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/BundleContributer.cs @@ -5,16 +5,24 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly.Theming { public class BundleContributer : IBundleContributer { - public void AddScripts(List scripts) + public void AddScripts(List scriptDefinitions) { } - public void AddStyles(List styles) + public void AddStyles(List styleDefinitions) { - styles.AddIfNotContains("_content/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/libs/bootstrap/css/bootstrap.css"); - styles.AddIfNotContains("_content/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/libs/fontawesome/css/all.css"); - styles.AddIfNotContains("_content/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/libs/flag-icon/css/flag-icon.css"); + var styles = new string[] + { + "_content/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/libs/bootstrap/css/bootstrap.min.css", + "_content/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/libs/fontawesome/css/all.css", + "_content/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/libs/flag-icon/css/flag-icon.css" + }; + + foreach (var style in styles) + { + styleDefinitions.AddIfNotContains((item) => item.Source == style, () => new BundleDefinition(style)); + } } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/BundleContributer.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/BundleContributer.cs index 4d65f03e4e..99fcde7b97 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/BundleContributer.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/BundleContributer.cs @@ -5,14 +5,21 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly { public class BundleContributer : IBundleContributer { - public void AddScripts(List scripts) + public void AddScripts(List scriptDefinitions) { - scripts.AddIfNotContains("_content/Volo.Abp.AspNetCore.Components.WebAssembly/libs/abp/js/abp.js"); + var scripts = new string[] + { + "_content/Volo.Abp.AspNetCore.Components.WebAssembly/libs/abp/js/abp.js", + }; + + foreach (var script in scripts) + { + scriptDefinitions.AddIfNotContains((item) => item.Source == script, () => new BundleDefinition(script)); + } } - public void AddStyles(List styles) + public void AddStyles(List styleDefinitions) { - } } } diff --git a/framework/src/Volo.Abp.BlazoriseUI/BundleContributer.cs b/framework/src/Volo.Abp.BlazoriseUI/BundleContributer.cs index 10e35c5e10..2b182f465f 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/BundleContributer.cs +++ b/framework/src/Volo.Abp.BlazoriseUI/BundleContributer.cs @@ -5,17 +5,33 @@ namespace Volo.Abp.BlazoriseUI { public class BundleContributer : IBundleContributer { - public void AddScripts(List scripts) + public void AddScripts(List scriptDefinitions) { - scripts.AddIfNotContains("_content/Blazorise/blazorise.js"); - scripts.AddIfNotContains("_content/Blazorise.Bootstrap/blazorise.bootstrap.js"); + var scripts = new string[] + { + "_content/Blazorise/blazorise.js", + "_content/Blazorise.Bootstrap/blazorise.bootstrap.js" + }; + + foreach (var script in scripts) + { + scriptDefinitions.AddIfNotContains((item) => item.Source == script, () => new BundleDefinition(script)); + } } - public void AddStyles(List styles) + public void AddStyles(List styleDefinitions) { - styles.AddIfNotContains("_content/Blazorise/blazorise.css"); - styles.AddIfNotContains("_content/Blazorise.Bootstrap/blazorise.bootstrap.css"); - styles.AddIfNotContains("_content/Blazorise.Snackbar/blazorise.snackbar.css"); + var styles = new string[] + { + "_content/Blazorise/blazorise.css", + "_content/Blazorise.Bootstrap/blazorise.bootstrap.css", + "_content/Blazorise.Snackbar/blazorise.snackbar.css" + }; + + foreach (var style in styles) + { + styleDefinitions.AddIfNotContains((item) => item.Source == style, () => new BundleDefinition(style)); + } } } } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/BundleDefinition.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/BundleTypeDefinition.cs similarity index 80% rename from framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/BundleDefinition.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/BundleTypeDefinition.cs index fef5e3d5d2..5fc9ecadeb 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/BundleDefinition.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/BundleTypeDefinition.cs @@ -2,7 +2,7 @@ namespace Volo.Abp.Cli.Bundling { - internal class BundleDefinition + internal class BundleTypeDefinition { public int Level { get; set; } public Type BundleContributerType { get; set; } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/BundlingService.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/BundlingService.cs index f2f8e24a3c..8610b3da4d 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/BundlingService.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/BundlingService.cs @@ -1,4 +1,5 @@ -using Microsoft.Extensions.Logging; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.IO; @@ -50,7 +51,7 @@ namespace Volo.Abp.Cli.Bundling var assemblyFilePath = GetAssemblyFilePath(directory, frameworkVersion, Path.GetFileNameWithoutExtension(projectFilePath)); var startupModule = GetStartupModule(assemblyFilePath); - var bundleDefinitions = new List(); + var bundleDefinitions = new List(); FindBundleContributersRecursively(startupModule, 0, bundleDefinitions); bundleDefinitions = bundleDefinitions.OrderByDescending(t => t.Level).ToList(); @@ -92,9 +93,9 @@ namespace Volo.Abp.Cli.Bundling return updatedContent.Insert(placeholderStartIndex, definitions); } - private string GenerateStyleDefinitions(List bundleDefinitions) + private string GenerateStyleDefinitions(List bundleDefinitions) { - var styles = new List(); + var styles = new List(); foreach (var bundleDefinition in bundleDefinitions) { var contributer = CreateContributerInstance(bundleDefinition.BundleContributerType); @@ -105,18 +106,30 @@ namespace Volo.Abp.Cli.Bundling builder.AppendLine($"{StylePlaceholderStart}"); foreach (var style in styles) { - builder.AppendLine($"\t"); + if (style.AdditionalProperties != null && style.AdditionalProperties.Any()) + { + builder.Append($"\t"); + } + else + { + builder.AppendLine($"\t"); + } } builder.AppendLine($"\t{StylePlaceholderEnd}"); return builder.ToString(); } - private string GenerateScriptDefinitions(List bundleDefinitions) + private string GenerateScriptDefinitions(List bundleDefinitions) { - var scripts = new List + var scripts = new List { - "_framework/blazor.webassembly.js" + new BundleDefinition("_framework/blazor.webassembly.js") }; foreach (var bundleDefinition in bundleDefinitions) { @@ -128,7 +141,19 @@ namespace Volo.Abp.Cli.Bundling builder.AppendLine($"{ScriptPlaceholderStart}"); foreach (var script in scripts) { - builder.AppendLine($"\t"); + if (script.AdditionalProperties != null && script.AdditionalProperties.Any()) + { + builder.Append($"\t"); + } + else + { + builder.AppendLine($"\t"); + } } builder.AppendLine($"\t{ScriptPlaceholderEnd}"); @@ -141,7 +166,7 @@ namespace Volo.Abp.Cli.Bundling return instance.As(); } - private void FindBundleContributersRecursively(Type module, int level, List bundleDefinitions) + private void FindBundleContributersRecursively(Type module, int level, List bundleDefinitions) { var dependencyDescriptors = module .GetCustomAttributes() @@ -160,7 +185,7 @@ namespace Volo.Abp.Cli.Bundling } else { - bundleDefinitions.Add(new BundleDefinition + bundleDefinitions.Add(new BundleTypeDefinition { Level = level, BundleContributerType = bundleContributer diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Bundling/BundleDefinition.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Bundling/BundleDefinition.cs new file mode 100644 index 0000000000..2bc82a86ef --- /dev/null +++ b/framework/src/Volo.Abp.Core/Volo/Abp/Bundling/BundleDefinition.cs @@ -0,0 +1,16 @@ +using System.Collections.Generic; + +namespace Volo.Abp.Bundling +{ + public class BundleDefinition + { + public string Source { get; set; } + public Dictionary AdditionalProperties { get; set; } + + public BundleDefinition(string source) + { + Source = source; + AdditionalProperties = new Dictionary(); + } + } +} diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Bundling/IBundleContributer.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Bundling/IBundleContributer.cs index c9201fe007..2bf8dfff85 100644 --- a/framework/src/Volo.Abp.Core/Volo/Abp/Bundling/IBundleContributer.cs +++ b/framework/src/Volo.Abp.Core/Volo/Abp/Bundling/IBundleContributer.cs @@ -1,12 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Text; +using System.Collections.Generic; namespace Volo.Abp.Bundling { public interface IBundleContributer { - void AddScripts(List scripts); - void AddStyles(List styles); + void AddScripts(List scriptDefinitions); + void AddStyles(List styleDefinitions); } } diff --git a/framework/src/Volo.Abp.Http.Client.IdentityModel.WebAssembly/Volo/Abp/Http/Client/IdentityModel/WebAssembly/BundleContributer.cs b/framework/src/Volo.Abp.Http.Client.IdentityModel.WebAssembly/Volo/Abp/Http/Client/IdentityModel/WebAssembly/BundleContributer.cs index da4c01512a..b7932866ad 100644 --- a/framework/src/Volo.Abp.Http.Client.IdentityModel.WebAssembly/Volo/Abp/Http/Client/IdentityModel/WebAssembly/BundleContributer.cs +++ b/framework/src/Volo.Abp.Http.Client.IdentityModel.WebAssembly/Volo/Abp/Http/Client/IdentityModel/WebAssembly/BundleContributer.cs @@ -1,18 +1,26 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using Volo.Abp.Bundling; namespace Volo.Abp.Http.Client.IdentityModel.WebAssembly { public class BundleContributer : IBundleContributer { - public void AddScripts(List scripts) + public void AddScripts(List scriptDefinitions) { - scripts.AddIfNotContains("_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js"); + var scripts = new string[] + { + "_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js", + }; + + foreach (var script in scripts) + { + scriptDefinitions.AddIfNotContains((item) => item.Source == script, () => new BundleDefinition(script)); + } } - public void AddStyles(List styles) + public void AddStyles(List styleDefinitions) { + } } }