在r.js中停用uglyfying [英] Disable uglyfying in r.js

查看:94
本文介绍了在r.js中停用uglyfying的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法来防止r.js(RequireJS的优化脚本)丑陋地欺骗我们的JS模块,以保持可读性以进行调试. 我希望脚本(顺便在Node.js上运行)具有一些命令行选项可以传递. 不幸的是,如果此工具相当差,那么文档.

I am looking for a way to prevent r.js (RequireJS' optimization script) from ugylyfying our JS-modules to maintain readability for debugging purposes. I expect the script (running on Node.js by the way) to have some command line option to be passed. Unfortunately, the documentation if this tool is rather poor.

推荐答案

在命令行中将optimize=none传递给r.js,或在构建脚本中包含optimize: "none".

Pass optimize=none on the command line to r.js, or include optimize: "none" in your build script.

例如:

({
    baseUrl: ".",
    paths: {
        jquery: "some/other/jquery"
    },
    name: "main",
    out: "main-built.js",
    optimize: "none"
})

有关更多信息,请参见 http://requirejs.org/docs/optimization.html .

See http://requirejs.org/docs/optimization.html for more information.

如果您检查来源,您会看到默认设置为"uglify".以下是可接受的选项:

If you check the source, you will see that the default is set to "uglify". Here are the options which are accepted:

  • uglify :(默认)使用UglifyJS缩小代码.
  • uglify2:在2.1.2+版本中.使用UglifyJS2.
  • closure:在简单的优化模式下使用Google的Closure Compiler来减少代码.仅在使用Java运行优化器时可用.
  • closure.keepLines:与闭包选项相同,但将行返回保留在缩小的文件中.
  • none:不会缩小.
  • uglify: (default) uses UglifyJS to minify the code.
  • uglify2: in version 2.1.2+. Uses UglifyJS2.
  • closure: uses Google's Closure Compiler in simple optimization mode to minify the code. Only available if running the optimizer using Java.
  • closure.keepLines: Same as closure option, but keeps line returns in the minified files.
  • none: no minification will be performed.

这篇关于在r.js中停用uglyfying的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆