Setting up Smidge
This commit is contained in:
@@ -10,7 +10,7 @@ namespace Umbraco.Core.Runtime
|
||||
string GetHashValue { get; }
|
||||
|
||||
//return type HtmlHelper
|
||||
string RequiresCss(string filePath, string pathNameAlias);
|
||||
string RequiresCss(string filePath, string bundleName);
|
||||
|
||||
//return type IHtmlString
|
||||
//IClientDependencyPath[]
|
||||
|
||||
+25
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Smidge;
|
||||
using Smidge.Models;
|
||||
|
||||
namespace Umbraco.Web.BackOffice.AspNetCore
|
||||
{
|
||||
@@ -12,6 +14,29 @@ namespace Umbraco.Web.BackOffice.AspNetCore
|
||||
throw new ArgumentNullException(nameof(app));
|
||||
}
|
||||
|
||||
app.UseRuntimeMinifier();
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
public static IApplicationBuilder UseRuntimeMinifier(this IApplicationBuilder app)
|
||||
{
|
||||
app.UseSmidge(bundles =>
|
||||
{
|
||||
bundles.Create("default-css",
|
||||
new CssFile("~/assets/css/umbraco.css"),
|
||||
new CssFile("~/lib/bootstrap-social/bootstrap-social.css"),
|
||||
new CssFile("~/lib/font-awesome/css/font-awesome.min.css"));
|
||||
|
||||
bundles.Create("index-css",
|
||||
new CssFile("assets/css/canvasdesigner.css"));
|
||||
|
||||
bundles.Create("default-js", WebFileType.Js,
|
||||
"//cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js",
|
||||
"//cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.0/jquery.validate.min.js",
|
||||
"//cdnjs.cloudflare.com/ajax/libs/jquery-validation-unobtrusive/3.2.11/jquery.validate.unobtrusive.min.js");
|
||||
});
|
||||
|
||||
return app;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
using System.Configuration;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Smidge;
|
||||
using Umbraco.Composing;
|
||||
using Umbraco.Configuration;
|
||||
using Umbraco.Core;
|
||||
@@ -48,6 +51,8 @@ namespace Umbraco.Web.BackOffice.AspNetCore
|
||||
hostApplicationLifetime,
|
||||
configs);
|
||||
|
||||
services.AddRuntimeMinifier();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
@@ -78,5 +83,12 @@ namespace Umbraco.Web.BackOffice.AspNetCore
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
public static IServiceCollection AddRuntimeMinifier(this IServiceCollection services)
|
||||
{
|
||||
services.AddSmidge((IConfiguration) ConfigurationManager.GetSection("smidge"));
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Smidge;
|
||||
using Smidge.Cache;
|
||||
using Smidge.FileProcessors;
|
||||
using Smidge.Nuglify;
|
||||
using Smidge.Models;
|
||||
using Umbraco.Core.Assets;
|
||||
using Umbraco.Core.Runtime;
|
||||
|
||||
namespace Umbraco.Web.BackOffice.Smidge
|
||||
{
|
||||
public class SmidgeRuntimeMinifier : IRuntimeMinifier
|
||||
{
|
||||
private readonly SmidgeHelper _smidge;
|
||||
public string GetHashValue => new SmidgeConfig((IConfiguration) ConfigurationManager.GetSection("smidge")).Version;
|
||||
|
||||
public SmidgeRuntimeMinifier(SmidgeHelper smidge)
|
||||
{
|
||||
_smidge = smidge;
|
||||
}
|
||||
public string RequiresCss(string filePath, string bundleName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public string RenderCssHere(params string[] path)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public string RequiresJs(string filePath)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public string RenderJsHere()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetAssetPaths(AssetType assetType, List<IAssetFile> attributes)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public string Minify(string src)
|
||||
{
|
||||
//TextReader reader = new StringReader(src);
|
||||
// var jsMinifier = new NuglifyJs();
|
||||
|
||||
// return jsMinifier.ProcessAsync();
|
||||
return "";
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public string GetScriptForBackOffice()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetAssetList()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,11 @@
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Smidge" Version="3.1.0" />
|
||||
<PackageReference Include="Smidge.Nuglify" Version="2.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Umbraco.Configuration\Umbraco.Configuration.csproj" />
|
||||
<ProjectReference Include="..\Umbraco.Core\Umbraco.Core.csproj" />
|
||||
|
||||
@@ -80,10 +80,14 @@
|
||||
{"Char": ";", "Replacement": ""},
|
||||
{"Char": "/", "Replacement": ""},
|
||||
{"Char": "\\", "Replacement": ""},
|
||||
{"Char": ":", "Replacement": ""},
|
||||
{"Char": ":", "Replacement": ""}
|
||||
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"smidge": {
|
||||
"dataFolder" : "App_Data/Smidge",
|
||||
"version" : "1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Umbraco.Web.JavaScript.CDF
|
||||
_htmlHelper = new HtmlHelper(new ViewContext(), new ViewPage());
|
||||
}
|
||||
|
||||
public string RequiresCss(string filePath, string pathNameAlias)
|
||||
public string RequiresCss(string filePath, string bundleName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
//_htmlHelper.ViewContext.GetLoader().RegisterDependency(filePath, pathNameAlias, ClientDependencyType.Css);
|
||||
|
||||
Reference in New Issue
Block a user