如何在没有Node.JS的情况下运行UglifyJS2 [英] How to run UglifyJS2 without Node.JS

查看:241
本文介绍了如何在没有Node.JS的情况下运行UglifyJS2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论如何在没有node.js的情况下运行 UglifyJS2 ?假设我想使用JavaScript脚本引擎在JVM进程中运行它。怎么做?

Anyway to run UglifyJS2 without node.js? Say I would like to run it in a JVM process using JavaScript script engine. How to do that?

推荐答案

我看到mishoo回答你
https://github.com/mishoo/UglifyJS2/issues/122

I saw mishoo answered you https://github.com/mishoo/UglifyJS2/issues/122

两种可能的方式:


  • 运行 uglifyjs - self 获取可以在浏览器(或任何JS环境)中加载的UglifyJS的构建,您可以使用API​​ 此处描述

  • run uglifyjs --self to get a build of UglifyJS that you can load in a browser (or in any JS environment) and you can use the API described here.

在您的环境中加载lib /目录中的所有文件(加载 utils.js ast.js 首先,其他人可以按任何顺序进入)。如果你这样做,一切都将是全局的 - 你可以使用相同的API,但不需要为UglifyJS添加前缀..

load in your environment all files in the lib/ directory (load utils.js and ast.js first, the others can come in whatever order). If you do this, everything will be global—you can use the same API but there's no need to prefix stuff with UglifyJS..

您也可以查看 tools / node.js ,了解我们如何在Node中加载它(因为我们没有使用标准要求)。

Also you might want to look at tools/node.js to see how we load it in Node (as we're not using the standard require).

这篇关于如何在没有Node.JS的情况下运行UglifyJS2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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