【发布时间】: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
【问题讨论】: