如何使用 google 关闭 REST 服务从 javascript 中删除调试代码。我知道我必须像这样为 JS 编译器指定调试变量:--define='DEBUG=false'(在 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