When running the following command:
echo "let demo = 3; console.log(demo);" | uglifyjs --compress --mangle
I would expect the following output:
let a=3;console.log(a);
Instead, I get:
let demo=3;console.log(demo);
Therefore, I don't understand how I should use --mangle
option. The official documentation explains how to exclude the names which shouldn't be mangled, how to mangle properties, etc., but how do I just transform the names of ordinary variables?
Or is this option doing something completely different, and I misunderstood its purpose?
Note: I'm using uglify-es 3.2.2.
When running the following command:
echo "let demo = 3; console.log(demo);" | uglifyjs --compress --mangle
I would expect the following output:
let a=3;console.log(a);
Instead, I get:
let demo=3;console.log(demo);
Therefore, I don't understand how I should use --mangle
option. The official documentation explains how to exclude the names which shouldn't be mangled, how to mangle properties, etc., but how do I just transform the names of ordinary variables?
Or is this option doing something completely different, and I misunderstood its purpose?
Note: I'm using uglify-es 3.2.2.
Share Improve this question asked Dec 29, 2017 at 17:03 Arseni MourzenkoArseni Mourzenko 52.3k35 gold badges118 silver badges210 bronze badges 2- did you try "uglifyjs --compress --mangle --toplevel" ? should mangle everything in the top level scope – MercyDude Commented Dec 29, 2017 at 17:23
- 2 @MercyDude: nice! Please, post it as an answer so I can accept it. – Arseni Mourzenko Commented Dec 29, 2017 at 17:36
1 Answer
Reset to default 16So I looked at The official documentation, and as you said --mangle
is the option where you choose what not to mangle (how convenient), and figured out that you should use --toplevel
which mangle everything in the top level scope.
Eventually it should look like that:
uglifyjs --compress --mangle --toplevel