Hello everyone.
I want to be able to use @Scripts.Render(“~/Script/js”) and @Styles.Render(“~/Content/css”)
After some research i came up with this.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Optimization;
using Umbraco.Core;
namespace MySolution.App_Code
{
public class CustomEventHandler : IApplicationEventHandler
{
public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
RegisterStyles(BundleTable.Bundles);
RegisterJavascript(BundleTable.Bundles);
}
private static void RegisterStyles(BundleCollection bundles)
{
bundles.Add(new StyleBundle("~/Content/styles").Include(
"~/css/*.css"
)
);
}
private static void RegisterJavascript(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/Script/js").Include(
"~/scripts/jquery/*.js"
)
);
}
}
}
-
Now System.Web.Optimization couldn’t be found.
-
Then i used : PM> Install-Package Microsoft.AspNet.Web.Optimization
-
Now i got no errors in my built. BUT…
-
Then i got a Newtonsoft.Json assembly error referance.
WRN : Logging assemblybinding is disabled .
Logging assemblybindingserror activated by setting the registry value [ HKLM \ Software \ Microsoft \ Fusion ! EnableLog ] ( DWORD ) at 1.
Note The performance impaired by logging assemblybindingserror .
This function is disabled by removing the registry value [ HKLM \ Software \ Microsoft \ Fusion ! EnableLog ] .
I hope someone can help.
This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/72069-how-to-bundle-css-and-js-using-systemweboptimization