How to run UglifyJS2 without Node.JS

安稳与你 提交于 2020-02-21 13:00:08

问题


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?


回答1:


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

Two possible ways:

  • 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.

  • 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..

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).



来源:https://stackoverflow.com/questions/14764529/how-to-run-uglifyjs2-without-node-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!