@@ -49,14 +49,16 @@ const buildTerserOptions = ({
49
49
safari10,
50
50
} ) ;
51
51
52
+ const someCommentsRegExp = / ^ \* * ! | @ p r e s e r v e | @ l i c e n s e | @ c c _ o n / i;
53
+
52
54
const buildComments = ( options , terserOptions , extractedComments ) => {
53
55
const condition = { } ;
54
56
const commentsOpts = terserOptions . output . comments ;
55
57
56
58
// Use /^\**!|@preserve|@license|@cc_on/i RegExp
57
59
if ( typeof options . extractComments === 'boolean' ) {
58
60
condition . preserve = commentsOpts ;
59
- condition . extract = / ^ \* * ! | @ p r e s e r v e | @ l i c e n s e | @ c c _ o n / i ;
61
+ condition . extract = someCommentsRegExp ;
60
62
} else if (
61
63
typeof options . extractComments === 'string' ||
62
64
options . extractComments instanceof RegExp
@@ -72,7 +74,11 @@ const buildComments = (options, terserOptions, extractedComments) => {
72
74
) {
73
75
// Extract condition is given in extractComments.condition
74
76
condition . preserve = commentsOpts ;
75
- condition . extract = options . extractComments . condition ;
77
+ condition . extract =
78
+ typeof options . extractComments . condition === 'boolean' &&
79
+ options . extractComments . condition
80
+ ? 'some'
81
+ : options . extractComments . condition ;
76
82
} else {
77
83
// No extract condition is given. Extract comments that match commentsOpts instead of preserving them
78
84
condition . preserve = false ;
@@ -102,7 +108,7 @@ const buildComments = (options, terserOptions, extractedComments) => {
102
108
condition [ key ] = ( astNode , comment ) => {
103
109
return (
104
110
comment . type === 'comment2' &&
105
- / ^ \* * ! | @ p r e s e r v e | @ l i c e n s e | @ c c _ o n / i . test ( comment . value )
111
+ someCommentsRegExp . test ( comment . value )
106
112
) ;
107
113
} ;
108
114
0 commit comments