From 87d850948f4ebccb0e3a47eb5c400376b8e8bf99 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Mon, 4 Dec 2023 18:05:55 +0000 Subject: [PATCH] PERF: Only apply terser to production assets (#24699) We funnel vendored javascript through ember-cli, but that's only used for the testem environment. Therefore, there's no need to minify it in production builds. In my tests, this reduces peak RSS of a production build from 3.53GB to 3.15GB. --- .../javascripts/discourse/ember-cli-build.js | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/discourse/ember-cli-build.js b/app/assets/javascripts/discourse/ember-cli-build.js index 16a838cb2df..1718aedfad3 100644 --- a/app/assets/javascripts/discourse/ember-cli-build.js +++ b/app/assets/javascripts/discourse/ember-cli-build.js @@ -141,16 +141,20 @@ module.exports = function (defaults) { parsePluginClientSettings(discourseRoot, vendorJs, app), funnel(`${discourseRoot}/public/javascripts`, { destDir: "javascripts" }), generateWorkboxTree(), - concat(adminTree, { - inputFiles: ["**/*.js"], - outputFile: `assets/admin.js`, - }), - concat(wizardTree, { - inputFiles: ["**/*.js"], - outputFile: `assets/wizard.js`, - }), - generateScriptsTree(app), - discoursePluginsTree, + applyTerser( + concat(adminTree, { + inputFiles: ["**/*.js"], + outputFile: `assets/admin.js`, + }) + ), + applyTerser( + concat(wizardTree, { + inputFiles: ["**/*.js"], + outputFile: `assets/wizard.js`, + }) + ), + applyTerser(generateScriptsTree(app)), + applyTerser(discoursePluginsTree), testStylesheetTree, ]; @@ -261,5 +265,5 @@ module.exports = function (defaults) { }, }); - return mergeTrees([appTree, applyTerser(mergeTrees(extraPublicTrees))]); + return mergeTrees([appTree, mergeTrees(extraPublicTrees)]); };