简体   繁体   English

如何不编译goog.closure中的某些代码ADVANCED_OPTIMIZATIONS

[英]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.

相关问题 如何在ADVANCED_OPTIMIZATIONS中的Closure Compiler中导出公共类方法? - How to export public class methods in Closure Compiler in ADVANCED_OPTIMIZATIONS? 具有Closure Compiler和ADVANCED_OPTIMIZATIONS的模块模式 - Module pattern with Closure Compiler and ADVANCED_OPTIMIZATIONS 使用闭包编译器 ADVANCED_OPTIMIZATIONS 的奇怪对象属性行为 - strange object property behavior with closure compiler ADVANCED_OPTIMIZATIONS Google Closure Compiler ADVANCED_OPTIMIZATIONS - 排除所有函数名称 - Google Closure Compiler ADVANCED_OPTIMIZATIONS - Exclude All function names 是否可以使用闭包编译器ADVANCED_OPTIMIZATIONS与jQuery? - Is it possible to use Closure Compiler ADVANCED_OPTIMIZATIONS with jQuery? Google Closure编译器的ADVANCED_OPTIMIZATIONS选项 - Google Closure Compiler's ADVANCED_OPTIMIZATIONS option 关闭编译ADVANCED_OPTIMIZATIONS抱怨使用此方法 - closure compilation ADVANCED_OPTIMIZATIONS complaining about use of this 是否可以避免使用带有getter和setter的模式,而仍然使用Closure ADVANCED_OPTIMIZATIONS最小化JavaScript? - Can a pattern with getters and setters be avoided and still minify JavaScript with Closure ADVANCED_OPTIMIZATIONS? 具有高级优化和外部功能的Closure编译器 - Closure Compiler with Advanced Optimizations and Externs 闭包编译器,缺少具有高级优化功能的方法? - Closure Compiler, missing method with advanced optimizations?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM