From 33c5de9b8f82bd06ab20d1b0837697feae05ff98 Mon Sep 17 00:00:00 2001 From: Simon Leigh Date: Tue, 17 Dec 2019 20:21:31 +0900 Subject: [PATCH] fixed bug causing memory issues --- webpack.config.ts | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/webpack.config.ts b/webpack.config.ts index dfd5a57927..9dfd9657e3 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -22,16 +22,6 @@ module.exports = (env, argv) => { devtool: 'inline-source-map', - optimization: { - minimize: true, - minimizer: [ - new TerserPlugin({ - terserOptions: { - keep_fnames: /Block|Value|Bool|BooleanLiteral|Null|NullLiteral|Literal|NumberLiteral|StringLiteral|RegexLiteral|Arr|Obj|Op|Parens/ - } - }) - ] - }, module: { rules: [ @@ -100,7 +90,7 @@ module.exports = (env, argv) => { hot: true, // enable HMR on the server - before: function(app, server) { + before: function (app, server) { app.use( '/app/codemirror/mode', express.static(path.join(__dirname, 'node_modules/codemirror/mode')) @@ -132,7 +122,20 @@ module.exports = (env, argv) => { 'webpack-dev-server/client?http://localhost:3000', 'webpack/hot/only-dev-server' ) - ;(config.output as any).publicPath = '/app' + ; (config.output as any).publicPath = '/app' + } + + if (argv.mode === 'production') { + (config as any).optimization = { + minimize: true, + minimizer: [ + new TerserPlugin({ + terserOptions: { + keep_fnames: /Block|Value|Bool|BooleanLiteral|Null|NullLiteral|Literal|NumberLiteral|StringLiteral|RegexLiteral|Arr|Obj|Op|Parens/ + } + }) + ] + } } return config