From b611c307d77ff8cf002b26a0270c067de92665cc Mon Sep 17 00:00:00 2001 From: Alf Eaton <75253002+aeaton-overleaf@users.noreply.github.com> Date: Tue, 9 Feb 2021 15:39:13 +0000 Subject: [PATCH] Set TerserPlugin to not minify *Error classes/functions (#3615) Set the `keep_classnames` and `keep_fnames` options for TerserPlugin, to keep OError and subclass names intact so they can be accessed by this.constructor.name GitOrigin-RevId: 109fb81558b977ccc4acdb69f8544f7693940919 --- services/web/webpack.config.prod.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/services/web/webpack.config.prod.js b/services/web/webpack.config.prod.js index 6d158e1f18..b5ae83d794 100644 --- a/services/web/webpack.config.prod.js +++ b/services/web/webpack.config.prod.js @@ -42,7 +42,15 @@ module.exports = merge.smart( optimization: { // Minify JS (with Terser) and CSS (with cssnano) - minimizer: [new TerserPlugin(), new OptimizeCssAssetsPlugin()] + minimizer: [ + new TerserPlugin({ + terserOptions: { + keep_classnames: /Error$/, + keep_fnames: /Error$/ + } + }), + new OptimizeCssAssetsPlugin() + ] }, plugins: [