How to keep /*! comments with UglifyJS2?

↘锁芯ラ 提交于 2019-12-11 02:33:50

问题


The default behaviour looks for @license or @preserve...

But many plugins and libraries are still using /*! for licensing comment blocks...

How can I use UglifyJS2 to preserve comments starting with /*! ?


回答1:


See https://github.com/mishoo/UglifyJS2#usage

Using the --comments argument, you can supply a regular expression.

uglifyjs jquery.plugin.js --comments '/^\/*!/' -o outfile.js



回答2:


In case that you use this VSCode extension JS & CSS Minifier (Minify), you can configure it easily. Just add a .uglifyrc file on your project root and add the following content to your file:

  {
      "output": {
        "comments": "/^\/*!/"
    }
  }

That will only preserve your license comments



来源:https://stackoverflow.com/questions/25232339/how-to-keep-comments-with-uglifyjs2

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