Adds separate call for css assets

This commit is contained in:
Bjarke Berg
2021-04-15 09:52:55 +02:00
parent 03002e16d3
commit f1dbf6584b
5 changed files with 21 additions and 12 deletions

View File

@@ -60,13 +60,22 @@ namespace Umbraco.Cms.Core.WebAssets
Task<string> RenderJsHereAsync(string bundleName);
/// <summary>
/// Returns the asset paths for the bundle name
/// Returns the asset paths for the JS bundle name
/// </summary>
/// <param name="bundleName"></param>
/// <returns>
/// If debug mode is enabled this will return all asset paths (not bundled), else it will return a bundle URL
/// </returns>
Task<IEnumerable<string>> GetAssetPathsAsync(string bundleName);
Task<IEnumerable<string>> GetJsAssetPathsAsync(string bundleName);
/// <summary>
/// Returns the asset paths for the css bundle name
/// </summary>
/// <param name="bundleName"></param>
/// <returns>
/// If debug mode is enabled this will return all asset paths (not bundled), else it will return a bundle URL
/// </returns>
Task<IEnumerable<string>> GetCssAssetPathsAsync(string bundleName);
/// <summary>
/// Minify the file content, of a given type

View File

@@ -17,8 +17,8 @@ namespace Umbraco.Extensions
/// <returns></returns>
public static async Task<string> GetScriptForLoadingBackOfficeAsync(this IRuntimeMinifier minifier, GlobalSettings globalSettings, IHostingEnvironment hostingEnvironment)
{
var coreScripts = await minifier.GetAssetPathsAsync(BackOfficeWebAssets.UmbracoCoreJsBundleName);
var extensionsScripts = await minifier.GetAssetPathsAsync(BackOfficeWebAssets.UmbracoExtensionsJsBundleName);
var coreScripts = await minifier.GetJsAssetPathsAsync(BackOfficeWebAssets.UmbracoCoreJsBundleName);
var extensionsScripts = await minifier.GetJsAssetPathsAsync(BackOfficeWebAssets.UmbracoExtensionsJsBundleName);
var result = BackOfficeJavaScriptInitializer.GetJavascriptInitialization(coreScripts.Union(extensionsScripts), "umbraco", globalSettings, hostingEnvironment);
result += await GetStylesheetInitializationAsync(minifier);
@@ -30,7 +30,7 @@ namespace Umbraco.Extensions
/// </summary>
private static async Task<string> GetStylesheetInitializationAsync(IRuntimeMinifier minifier)
{
var files = await minifier.GetAssetPathsAsync(BackOfficeWebAssets.UmbracoCssBundleName);
var files = await minifier.GetCssAssetPathsAsync(BackOfficeWebAssets.UmbracoCssBundleName);
var sb = new StringBuilder();
foreach (var file in files)
sb.AppendFormat("{0}LazyLoad.css('{1}');", Environment.NewLine, file);

View File

@@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ViewEngines;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Editors;
using Umbraco.Cms.Core.Features;
@@ -21,7 +22,6 @@ using Umbraco.Cms.Web.BackOffice.Filters;
using Umbraco.Cms.Web.Common.Authorization;
using Umbraco.Cms.Web.Common.Filters;
using Umbraco.Extensions;
using Constants = Umbraco.Cms.Core.Constants;
namespace Umbraco.Cms.Web.BackOffice.Controllers
{
@@ -105,7 +105,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
//[OutputCache(Order = 1, VaryByParam = "none", Location = OutputCacheLocation.Server, Duration = 5000)]
public async Task<JavaScriptResult> Application()
{
var files = await _runtimeMinifier.GetAssetPathsAsync(BackOfficeWebAssets.UmbracoPreviewJsBundleName);
var files = await _runtimeMinifier.GetJsAssetPathsAsync(BackOfficeWebAssets.UmbracoPreviewJsBundleName);
var result = BackOfficeJavaScriptInitializer.GetJavascriptInitialization(files, "umbraco.preview", _globalSettings, _hostingEnvironment);
return new JavaScriptResult(result);

View File

@@ -10,7 +10,6 @@ using Umbraco.Cms.Core.WebAssets;
using Umbraco.Cms.Infrastructure.WebAssets;
using Umbraco.Cms.Web.BackOffice.Controllers;
using Umbraco.Cms.Web.BackOffice.Security;
using Umbraco.Extensions;
namespace Umbraco.Extensions
{
@@ -124,7 +123,7 @@ namespace Umbraco.Extensions
public static async Task<IHtmlContent> AngularValueTinyMceAssetsAsync(this IHtmlHelper html, IRuntimeMinifier runtimeMinifier)
{
var files = await runtimeMinifier.GetAssetPathsAsync(BackOfficeWebAssets.UmbracoTinyMceJsBundleName);
var files = await runtimeMinifier.GetJsAssetPathsAsync(BackOfficeWebAssets.UmbracoTinyMceJsBundleName);
var sb = new StringBuilder();

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Options;
@@ -120,7 +119,7 @@ namespace Umbraco.Cms.Web.Common.RuntimeMinification
// use the cache buster defined in config
.SetCacheBusterType(_cacheBusterType))
.Build());
}
}
}
public async Task<string> RenderCssHereAsync(string bundleName) => (await _smidge.SmidgeHelper.CssHereAsync(bundleName, _hostingEnvironment.IsDebugMode)).ToString();
@@ -171,7 +170,9 @@ namespace Umbraco.Cms.Web.Common.RuntimeMinification
public async Task<string> RenderJsHereAsync(string bundleName) => (await _smidge.SmidgeHelper.JsHereAsync(bundleName, _hostingEnvironment.IsDebugMode)).ToString();
public async Task<IEnumerable<string>> GetAssetPathsAsync(string bundleName) => await _smidge.SmidgeHelper.GenerateJsUrlsAsync(bundleName, _hostingEnvironment.IsDebugMode);
public async Task<IEnumerable<string>> GetJsAssetPathsAsync(string bundleName) => await _smidge.SmidgeHelper.GenerateJsUrlsAsync(bundleName, _hostingEnvironment.IsDebugMode);
public async Task<IEnumerable<string>> GetCssAssetPathsAsync(string bundleName) => await _smidge.SmidgeHelper.GenerateCssUrlsAsync(bundleName, _hostingEnvironment.IsDebugMode);
/// <inheritdoc />
public async Task<string> MinifyAsync(string fileContent, AssetType assetType)