lautis / uglifier

Ruby wrapper for UglifyJS JavaScript compressor.
http://www.rubydoc.info/gems/uglifier
MIT License
613 stars 82 forks source link

define option incorrectly documented #75

Closed jneuendorf closed 9 years ago

jneuendorf commented 10 years ago

Hey,

I wanted to use the define option to replace a debug variable but it didn't work. After I tried around a bit I got it working after I put the :define => { "DEBUG" => false } into the :compress hash it worked. So apparently this option has to be defined in that hash instead of the top level (of all options) so the listed options aren't quite correct, I guess (https://github.com/lautis/uglifier -> Usage)

lautis commented 10 years ago

The following code works for me with latest Uglifier

Uglifier.compile("var a = STR", {define: {STR: "foo"}})
# => "var a=\"foo\";"

You could use compress hash too, but then the argument would need to be global_defs

Uglifier.compile("var a = STR", compress: {global_defs: {STR: "foo"}})

If you have an example that should work but doesn't, let me know and I'll update the documentation accordingly.