Permalink
Browse files

Add one more test for `preserveComments` option.

1 parent cc846ac commit 0511085edfbc0b8b9e7ea9eb47ba74b876fdd43f @XhmikosR XhmikosR committed Oct 31, 2016
View
@@ -113,6 +113,14 @@ module.exports = function(grunt) {
preserveComments: 'some'
}
},
+ commentsWithImportant: {
+ src: 'test/fixtures/src/comments.js',
+ dest: 'tmp/commentsWithImportant.js',
+ options: {
+ mangle: false,
+ preserveComments: /^!|@preserve|@license|@cc_on/i
+ }
+ },
wrap: {
src: 'test/fixtures/src/simple.js',
dest: 'tmp/wrap.js',
@@ -120,8 +120,9 @@ Turn on preservation of comments.
- `false` will strip all comments
- `'all'` will preserve all comments in code blocks that have not been squashed or dropped
-- `'some'` will preserve all comments that start with a bang (`!`) or include a closure compiler style directive (`@preserve` `@license` `@cc_on`)
+- `'some'` will preserve all comments that include a closure compiler style directive (`@preserve` `@license` `@cc_on`)
- `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`
+- `RegExp` `'/[RegExp]/'` will preserve comments matching given RegExp or stringified RegExp
## banner
Type: `String`
@@ -1,10 +1,4 @@
-/*!
- * I am a comment
- */
-function foo(){return 42}
-// @preserve preserve
-// @license license
-function bar(){return 2*foo()}/* @preserve
+function foo(){return 42}function bar(){return 2*foo()}/* @preserve
* multiline preserve
*/
/* @license
@@ -0,0 +1,13 @@
+/*!
+ * I am a comment
+ */
+function foo(){return 42}
+// @preserve preserve
+// @license license
+function bar(){return 2*foo()}/* @preserve
+ * multiline preserve
+ */
+/* @license
+ * multiline license
+ */
+function baz(){return bar()*bar()}
View
@@ -14,6 +14,7 @@ exports.contrib_uglify = {
var files = [
'beautify.js',
'comments.js',
+ 'commentsWithImportant.js',
'compress.js',
'compress_explicit.js',
'compress_mangle.js',

0 comments on commit 0511085

Please sign in to comment.