Search code examples
javascriptgruntjsuglifyjs

How can I disable UglifyJS chaining declarations with commas. I cannot use Breakpoints


UglifyJS uses commas to chain function, object and variable declarations. This is fine for productions and when the file is being minified however it makes it extremely hard to walk through the javascript with breakpoints when debugging js. I need to know how to turn this feature off in the UglifyJS Grunt Plugin.

Below is what the output looks like.

var boom = function(a) {
  ...
},
bing = function(b){
  ...
},
bam = function(c) {
  ...
};

Solution

  • Ok I figured it out. In the the Gruntfile under options > compress add an option

    sequences: false

    that will stop the semi-colons being replaced with commas. You can then use breakpoints like you would normally.

    uglify: {
        options: {
            compress: {
                sequences: false
            }
        }
    }