javascript 压缩 gulp-uglify 保留一个注释信息

在使用 gulp-uglify 压缩后 ,

想保留 一下注释

/*! 

...
  */
阅读 7.3k
2 个回答

preserveComments

A convenience option for options.output.comments. Defaults to preserving no comments.

all
Preserve all comments in code blocks

license
Attempts to preserve comments that likely contain licensing information, even if the comment does not have directives such as @license or /*!.

Implemented via the uglify-save-license module, this option preserves a comment if one of the following is true:

The comment is in the first line of a file
A regular expression matches the string of the comment. For example: MIT, @license, or Copyright.
There is a comment at the previous line, and it matches 1, 2, or 3.

function
Specify your own comment preservation function. You will be passed the current node and the current comment and are expected to return either true or false.

some (deprecated)
Preserve comments that start with a bang (!) or include a Closure Compiler directive (@preserve, @license, @cc_on). Deprecated in favor of the license option, documented above.

https://www.npmjs.com/package/gulp-uglify

通常版权注释会以 /*! 开头,或者包含 @license,@preserve。
这些特殊注释就被保留在压缩后的代码中,而不会被删除。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题