PERF: Minify admin and wizard JS bundles to match app (#17992)

This regressed when we switched these bundles to be compiled by ember-cli. Before/after sizes:

```
          before                  after
admin.js: 1370 KB (190 KB gz) --> 782 KB (125 KB gzipped)
wizard.js: 127 KB ( 22 KB gz) -->  68 KB ( 18 KB gzipped)
```
This commit is contained in:
David Taylor 2022-08-19 08:35:00 +01:00 committed by GitHub
parent 2d1e50911b
commit 66376a6569
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -134,6 +134,9 @@ module.exports = function (defaults) {
"/app/assets/javascripts/discourse/public/assets/scripts/module-shims.js"
);
const terserPlugin = app.project.findAddonByName("ember-cli-terser");
const applyTerser = (tree) => terserPlugin.postprocessTree("all", tree);
return mergeTrees([
createI18nTree(discourseRoot, vendorJs),
app.toTree(),
@ -142,14 +145,18 @@ module.exports = function (defaults) {
files: ["highlight-test-bundle.min.js"],
destDir: "assets/highlightjs",
}),
concat(mergeTrees([app.options.adminTree]), {
inputFiles: ["**/*.js"],
outputFile: `assets/admin.js`,
}),
concat(mergeTrees([app.options.wizardTree]), {
inputFiles: ["**/*.js"],
outputFile: `assets/wizard.js`,
}),
applyTerser(
concat(mergeTrees([app.options.adminTree]), {
inputFiles: ["**/*.js"],
outputFile: `assets/admin.js`,
})
),
applyTerser(
concat(mergeTrees([app.options.wizardTree]), {
inputFiles: ["**/*.js"],
outputFile: `assets/wizard.js`,
})
),
prettyTextEngine(vendorJs, "discourse-markdown"),
concat("public/assets/scripts", {
outputFile: `assets/start-discourse.js`,