SignalR hub.js minify

2019-07-20 06:01发布

The SignalR github repository extensibility at https://github.com/SignalR/SignalR/wiki/Extensibility indicates that you can replace the

IJavaScriptMinifier which I have done in the Global.asax Application_Start event:-

protected void Application_Start()
{
    Microsoft.AspNet.SignalR.GlobalHost.DependencyResolver.Register(typeof(Microsoft.AspNet.SignalR.Hubs.IJavaScriptMinifier), () => new Common.HubMin());

    // Register the default hubs route: ~/signalr
    RouteTable.Routes.MapHubs();
    ....
}


public class HubMin : Microsoft.AspNet.SignalR.Hubs.IJavaScriptMinifier
{
    public string Minify(string source)
    {
        CodeSettings settings = new CodeSettings
        {
          PreserveImportantComments = false,
          PreserveFunctionNames = true
        };
        Minifier doMin = new Minifier();
        string mind = doMin.MinifyJavaScript(source, settings);
        return mind;
    }
}

I have checked in the debugger that this function is being called and the minified source is being returned, however the hubs.js file still remains unminified.

Any clues??

标签: signalr
1条回答
老娘就宠你
2楼-- · 2019-07-20 06:56

This only works at runtime not if you're running SignalR.exe.

查看更多
登录 后发表回答