UglifyJS property mangling
Asked Answered
T

1

8

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, { ... })?

Transfiguration answered 15/6, 2015 at 8:47 Comment(1)
it seems such option is not supported so you would need to modify source code.Perzan
B
9

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.

Bartholomeus answered 28/6, 2015 at 21:28 Comment(1)
Can you somehow do the opposite? Like say that you mangle all the properties except the ones that start with an underscore?Dissimilitude

© 2022 - 2024 — McMap. All rights reserved.