Limit line length with requirejs + uglify

旧街凉风 提交于 2019-12-10 14:54:10

问题


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?


回答1:


Finally managed to figure out the necessary combination:

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


来源:https://stackoverflow.com/questions/20083717/limit-line-length-with-requirejs-uglify

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!