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`](d528103b7c/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`.
This commit is contained in:
Nicolò Ribaudo 2025-05-13 12:52:29 +02:00
parent 3f1ecc1ba9
commit ff432c39f9
No known key found for this signature in database
GPG Key ID: AAFDA9101C58F338

View File

@ -362,6 +362,9 @@ function createWebpackConfig(
// V8 chokes on very long sequences, work around that.
sequences: false,
},
format: {
comments: /@lic|webpackIgnore|@vite-ignore/i,
},
keep_classnames: true,
keep_fnames: true,
module: isModule,