katex: Update the `require` path to point to the new one.

This fixes #7620.
This commit is contained in:
rht 2018-01-20 04:17:28 +00:00 committed by showell
parent efbddce34d
commit 953478a189
1 changed files with 9 additions and 1 deletions

View File

@ -36,7 +36,15 @@ SOFTWARE.
let katex; let katex;
try { try {
// Attempt to import KaTeX from the production bundle // Attempt to import KaTeX from the production bundle
katex = require("/home/zulip/prod-static/min/katex.js"); const paths = require('/home/zulip/deployments/current/staticfiles.json').paths.values();
var katexPath = paths[paths.lastIndexOf('webpack-bundles/katex-')];
if (!katexPath.endsWith('js')) {
// This is to anticipate that the webpack staticfiles ordering may not be
// deterministic, that katex-somehash.js.map gets selected instead of
// katex-somehash.js
katexPath = paths[paths.indexOf('webpack-bundles/katex-')];
}
katex = require('/home/zulip/prod-static/' + katexPath);
} catch (ex) { } catch (ex) {
// Import KaTeX from node_modules (development environment) otherwise // Import KaTeX from node_modules (development environment) otherwise
katex = require("../../node_modules/katex/dist/katex.js"); katex = require("../../node_modules/katex/dist/katex.js");