Skip to content

Commit ff432c3

Browse files
Preserve webpack/vite ignore comments when minifying
They were removed in the minified build, but the code that made the comments necessary was still there (just minified). This commit updates the Terser config to preserve them. The default value of Terser's `comments` option is [`/@preserve|@copyright|@lic|@cc_on|^\**!/i`](https://github.com/terser/terser/blob/d528103b7c00735ca7736a2a8ad27188e93c0c90/lib/output.js#L178C12-L178C53), however the only type of comment it was actually matching in our case is `@lic`, for the license header in minified files. Thus the new regexp is `/@lic|webpackIgnore|@vite-ignore/i`.
1 parent 3f1ecc1 commit ff432c3

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

gulpfile.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,9 @@ function createWebpackConfig(
362362
// V8 chokes on very long sequences, work around that.
363363
sequences: false,
364364
},
365+
format: {
366+
comments: /@lic|webpackIgnore|@vite-ignore/i,
367+
},
365368
keep_classnames: true,
366369
keep_fnames: true,
367370
module: isModule,

0 commit comments

Comments
 (0)