在编译过程中删除调试器关键字,在google关闭中

问题描述 投票:0回答:1

我想知道是否有办法在编译过程中去掉 "debugger "这个关键字,我使用的是javascript版本。google-closure-compiler 与gulp。

通过查看文档,我们可以通过以下方式设置标志,在编译过程中停止显示错误信息。

https:/github.comgoogleclosure-compilerwikiFlags-and-Options。

--jscomp_off

把这个翻译成gulp,是这样的。

const googleClosureOptions = {
  ...
  jscomp_error:"checkDebuggerStatement"
}

然而这可以通过抛出错误或显示警告来停止编译。

zyxcdafg.js:1444: ERROR - [JSC_DEBUGGER_STATEMENT_PRESENT] Using the debugger statement can halt your application if the user has a JavaScript debugger running.
                    debugger;
                    ^^^^^^^^^

但我想实现的是删除调试器关键字。这是否可以使用googleclosure来实现。我找不到任何与此相关的标志或选项。

gulp google-closure-compiler google-closure
1个回答
0
投票

不,我不这么认为。我建议你用别的东西来做。比如说 sed:

find dist -name "*.js" -exec sed -i 's/\sdebugger;//' {} +

这样的事情会 find 文件在您 dist 的文件夹 结束于 .js 然后 exec-ute sed 替换所有的 debugger; 什么都没有。

你可以把它添加到一个调用你的Closure Compiler构建的脚本中。

© www.soinside.com 2019 - 2024. All rights reserved.