I solved it this way:
import TerserPlugin from "terser-webpack-plugin";
optimization: {
minimizer: [
(compiler: Compiler): void => {
new TerserPlugin({
terserOptions: {
format: {
comments: false
}
},
extractComments: false
}).apply(compiler);
}
]}
}