0

我声明以下 javascript

window.myApp = {};
myApp.myVeryLongFunctionName = function()
{
    ...
};

然后我用以下(在 C# 中)缩小 javascript

var minifiedCode = minifier.MinifyJavaScript(code, new CodeSettings
{
    RemoveUnneededCode = true,
    PreserveImportantComments = false,
    LocalRenaming = LocalRenaming.CrunchAll,
    EvalTreatment = EvalTreatment.MakeAllSafe,
    OutputMode = OutputMode.SingleLine,
    PreserveFunctionNames = false                        
});

但是“myApp”和“veryLongFunctionName”并没有被缩短,它被缩小到这个。

window.myApp={};myApp.myVeryLongFunctionName=function(){};

我希望将代码缩小为这样的东西。

window.a={};a.b=function(){};

我需要什么代码设置参数来实现这一点?

4

1 回答 1

0

MinifyJavaScript()将缩小后的代码作为字符串返回。尝试这个:

var s = minifier.MinifyJavaScript(code, new CodeSettings
{
  RemoveUnneededCode = true,
  PreserveImportantComments = false,
  LocalRenaming = LocalRenaming.CrunchAll,
  EvalTreatment = EvalTreatment.MakeAllSafe,
  OutputMode = OutputMode.SingleLine,
  PreserveFunctionNames = false                        
});
Console.WriteLine(s);
于 2015-08-18T06:50:42.553 回答