UglifyJS property mangling

不羁岁月 提交于 2019-12-08 16:57:03

问题


According to the docs, UglifyJS can mangle all property names except those on a provided reserved list. Is it possible to do it the other way, so only properties on provided list will be mangled?

If so, what options do I need to pass to uglify.minify(files, { ... })?


回答1:


One (ugly) command-line approach to achieve the kind of whitelist you're looking for might be to use the regex option.

You can also use a regular expression to define which property names should be mangled. For example, --mangle-regex="/^_/" will only mangle property names that start with an underscore.

UglifyJS2 Readme

Otherwise, there is an open issue which provides the code you could use to modify uglify yourself which achieves what I believe you're looking for.



来源:https://stackoverflow.com/questions/30840889/uglifyjs-property-mangling

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