【问题标题】:removing debug code with google closure REST service?使用谷歌关闭 REST 服务删除调试代码?
【发布时间】:2011-02-22 22:35:37
【问题描述】:

如何使用 google 关闭 REST 服务从 javascript 中删除调试代码。 我知道我必须像这样为 JS 编译器指定调试变量: --define='调试=假' (在 if 条件下使用 DEBUG)。 但是如何将其指定给 REST 服务:http://closure-compiler.appspot.com/home 我试过这个,但它不起作用。即:代码已优化但仍包含调试代码:(

// ==ClosureCompiler==
// @output_file_name default.js
// @compilation_level ADVANCED_OPTIMIZATIONS

-- define='DEBUG=false'

// ==/ClosureCompiler==


/** @define {boolean} */
var DEBUG = true;

/**@constructor*/
function MyObject() {
this.test = 4;
if (DEBUG) {
this.toString = function () { return "test object"; };
}
}
window['MyObject'] = MyObject

【问题讨论】:

    标签: google-closure-compiler


    【解决方案1】:

    Closure REST 服务通常将命令行选项映射到注释块之间的行。选项以“@”为前缀,去掉“=”符号。但是,它似乎不适用于@define(应该映射到--define)。我怀疑 REST 代码与 DEBUG=false 中的额外“=”混淆了。

    这应该可行:

    @define DEBUG=false
    

    @define 'DEBUG=false'
    

    但没有。

    【讨论】:

      【解决方案2】:

      REST 服务当前不支持define 参数。

      支持Only thesethese参数。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-12-08
        • 2013-12-03
        • 1970-01-01
        • 2010-09-17
        • 2011-04-06
        • 1970-01-01
        • 1970-01-01
        • 2015-10-25
        相关资源
        最近更新 更多