From 56395f40d2e24fa322aa62fdec110cb2493a8b7c Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Tue, 23 Jan 2018 12:06:41 -0800 Subject: [PATCH] static: Restore bundling KaTeX and zxcvbn via django-pipeline. Since we need KaTeX to be available for zerver/lib/tex.py and static/third/katex/cli.js to be able to shell out to it. However, for some reason, the KaTeX we bundle using Webpack doesn't seem to be importable by Node (and it's also kinda a pain to find its filename from `cli.js`). So, we work around this by just using the legacy system for KaTeX. Something similar is needed for zxcvbn.js, in order to support the settings_account.js use case (basically deferred loading of this file); that requires JS code to have access to the correct path for zxcvbn. --- zproject/settings.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/zproject/settings.py b/zproject/settings.py index 011743bebe..0848c18b55 100644 --- a/zproject/settings.py +++ b/zproject/settings.py @@ -1114,7 +1114,28 @@ JS_SPECS = { 'sockjs': { 'source_filenames': ['third/sockjs/sockjs-0.3.4.js'], 'output_filename': 'min/sockjs-0.3.4.min.js' - } + }, + # Even though we've moved the main KaTeX copy into Webpack, we + # also need KaTeX to be runnable directly via Node (Called from + # zerver/lib/tex.py which calls static/third/katex/cli.js. Since + # our Webpack setup doesn't provide a good way to name the current + # version of a module, we use the legacy django-pipeline system + # for bundling KaTeX. + 'katex': { + 'source_filenames': [ + 'node_modules/katex/dist/katex.js', + ], + 'output_filename': 'min/katex.js', + }, + # The same legacy treatment is required for zxcvbn, in order to + # support the settings_account.js use case (where we don't have a + # good way to look up the path to the file). + 'zxcvbn': { + 'source_filenames': [ + 'node_modules/zxcvbn/dist/zxcvbn.js', + ], + 'output_filename': 'min/zxcvbn.js' + }, } app_srcs = JS_SPECS['app']['source_filenames']