[英]How to not compile certain code in goog.closure ADVANCED_OPTIMIZATIONS
When I am using ADVANCED_OPTIMIZATIONS in closure, I can add to the web.config
attributes such: 当我在闭包中使用ADVANCED_OPTIMIZATIONS时,可以向
web.config
添加以下属性:
<compilation debug="false">
and than when I will write in my code: 而且比我写代码时要多:
if (goog.DEBUG) { code }
on advanced mode I will NOT see this script inside the .js file. 在高级模式下,我不会在.js文件中看到此脚本。
I would like to do the same with my own properties - I've created a define.js file: 我想对自己的属性做同样的事情-我创建了define.js文件:
Define.js: Define.js:
goog.scope(function() {
define.IS_SHOW_CODE = false;
}
and wrote code: if (!define.IS_SHOW_CODE) { code } 并编写了代码:if(!define.IS_SHOW_CODE){代码}
and I still CAN find this if and its content inside the compiled .js file! 而且我仍然可以在编译的.js文件中找到它及其内容!
How to prevent the closure from compiling script in advanced mode? 如何防止闭包在高级模式下编译脚本?
If "goog" works, likely you are missing the declaration of "define". 如果“ goog”有效,则可能您缺少“ define”的声明。
It should look something like this: 它看起来应该像这样:
var define = {}; // goog.provide('define') would also work here.
/** @define {boolean} */
define.IS_SHOW_CODE = true;
Ok i found how - i MUST use the prefix goog.[xxx] in order to tell the compiler to remove the script inside. 好的,我发现了-我必须使用前缀goog。[xxx]来告诉编译器删除其中的脚本。 using "define" instead didnt remove the script.
使用“定义”代替没有删除脚本。
so i've changed the define.IS_SHOW_CODE to goog.IS_SHOW_CODE 所以我已经将define.IS_SHOW_CODE更改为goog.IS_SHOW_CODE
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.