FIX: ember build was not adding digests to additional bundles (#12703)

* FIX: `ember build` was not adding digests to additional bundles

* Update app/assets/javascripts/discourse/ember-cli-build.js

Co-authored-by: Jarek Radosz <jradosz@gmail.com>

Co-authored-by: Jarek Radosz <jradosz@gmail.com>
This commit is contained in:
Robin Ward 2021-04-14 13:37:22 -04:00 committed by GitHub
parent 1d85574d52
commit 6a7a8f32f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,6 +8,7 @@ const prettyTextEngine = require("./lib/pretty-text-engine");
const { createI18nTree } = require("./lib/translation-plugin"); const { createI18nTree } = require("./lib/translation-plugin");
const discourseScss = require("./lib/discourse-scss"); const discourseScss = require("./lib/discourse-scss");
const funnel = require("broccoli-funnel"); const funnel = require("broccoli-funnel");
const AssetRev = require("broccoli-asset-rev");
module.exports = function (defaults) { module.exports = function (defaults) {
let discourseRoot = resolve("../../../.."); let discourseRoot = resolve("../../../..");
@ -20,6 +21,13 @@ module.exports = function (defaults) {
}, },
}); });
// Ember CLI does this by default for the app tree, but for our extra bundles we
// need to do it ourselves in production mode.
const isProduction = EmberApp.env().includes("production");
function digest(tree) {
return isProduction ? new AssetRev(tree) : tree;
}
// WARNING: We should only import scripts here if they are not in NPM. // WARNING: We should only import scripts here if they are not in NPM.
// For example: our very specific version of bootstrap-modal. // For example: our very specific version of bootstrap-modal.
app.import(vendorJs + "bootbox.js"); app.import(vendorJs + "bootbox.js");
@ -37,9 +45,11 @@ module.exports = function (defaults) {
files: ["highlight-test-bundle.min.js"], files: ["highlight-test-bundle.min.js"],
destDir: "assets/highlightjs", destDir: "assets/highlightjs",
}), }),
concat(app.options.adminTree, { digest(
outputFile: `assets/admin.js`, concat(app.options.adminTree, {
}), outputFile: `assets/admin.js`,
prettyTextEngine(vendorJs, "discourse-markdown"), })
),
digest(prettyTextEngine(vendorJs, "discourse-markdown")),
]); ]);
}; };