5

We're using requirejs.optimize(config) with uglify2 in our build scripts to minify our production JavaScript code. We want to limit the minified line length to about 80 chars, so that it will be easier to debug JavaScript errors even from the production code. (Most browsers only report the line number, not the column, in the onerror handler, so source maps do not help.)

Uglify2 contains the max-line-len option in the beautifier options. I've tried many different combinations of the following options, but haven't been able to get the code minified, but with limited line length:

config = {
  optimize: 'uglify2',
  uglify2: {
    output: {
      beautify: true
    },
    beautify: {
      beautify: false,
      max_line_len: 80
    }
  },
  // ...
}

How can I pass the option to limit the line length to uglify2?

Sampo
  • 2,619
  • 3
  • 25
  • 38

1 Answers1

5

Finally managed to figure out the necessary combination:

config = {
  optimize: 'uglify2',
  uglify2: {
    output: {
      max_line_len: 80
    }
  },
  // ...
}
Sampo
  • 2,619
  • 3
  • 25
  • 38