Search code examples
javascriptuglifyjs

how to uglify javascript wiithout minifying it?


I'm trying to debug some errors in my JS.

I usually use gulp + uglify to get an ugly minified one-liner. Now I need to get the file with the original lines intact to know which line gave me an error - but I'd still like to keep an atmosphere of mystique. Is there a way to mangle the code to make it less understandable without minifying it using uglifyjs?

Thanks


Solution

  • When you call uglify, you have the option to add the -b flag, which beautifies the output.

    The common way to approach this is indeed via sourcemaps as mentioned in the comments though. The grunt adapter for uglify for example or https://github.com/mishoo/UglifyJS2 (which is used by it) can generate those automatically for you via their sourcemap/--sourcemap option.