SignalR hub.js minify

荒凉一梦 提交于 2019-12-12 18:35:22

问题


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??


回答1:


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



来源:https://stackoverflow.com/questions/15035759/signalr-hub-js-minify

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!