@@ -49,14 +49,16 @@ const buildTerserOptions = ({
4949 safari10,
5050} ) ;
5151
52+ const someCommentsRegExp = / ^ \* * ! | @ p r e s e r v e | @ l i c e n s e | @ c c _ o n / i;
53+
5254const buildComments = ( options , terserOptions , extractedComments ) => {
5355 const condition = { } ;
5456 const commentsOpts = terserOptions . output . comments ;
5557
5658 // Use /^\**!|@preserve|@license|@cc_on/i RegExp
5759 if ( typeof options . extractComments === 'boolean' ) {
5860 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 ;
6062 } else if (
6163 typeof options . extractComments === 'string' ||
6264 options . extractComments instanceof RegExp
@@ -72,7 +74,11 @@ const buildComments = (options, terserOptions, extractedComments) => {
7274 ) {
7375 // Extract condition is given in extractComments.condition
7476 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 ;
7682 } else {
7783 // No extract condition is given. Extract comments that match commentsOpts instead of preserving them
7884 condition . preserve = false ;
@@ -102,7 +108,7 @@ const buildComments = (options, terserOptions, extractedComments) => {
102108 condition [ key ] = ( astNode , comment ) => {
103109 return (
104110 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 )
106112 ) ;
107113 } ;
108114
0 commit comments