UglifyJS财产损失 [英] UglifyJS property mangling

查看:91
本文介绍了UglifyJS财产损失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据文档,UglifyJS可以破坏除提供的保留列表上的属性名称之外的所有属性名称。是否有可能以其他方式执行此操作,因此只有提供列表中的属性会被破坏?

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?

如果是这样,我需要将哪些选项传递给 uglify.minify(files,{...})

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

推荐答案

一个(丑陋) )命令行方法来实现你正在寻找的那种白名单可能是使用正则表达式选项。

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


你也可以使用一个正则表达式,用于定义应修改哪些属性名称。例如, - mangle-regex =/ ^ _ /只会破坏以下划线开头的属性名称。

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.

< a href =https://github.com/mishoo/UglifyJS2\"rel =noreferrer> UglifyJS2自述文件

否则,有一个打开问题,它提供了你可以用来自己修改uglify的代码,它实现了我相信你的意思寻找。

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.

这篇关于UglifyJS财产损失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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