summaryrefslogtreecommitdiffstats
path: root/minify_web_js.py
diff options
context:
space:
mode:
authorCalum Lind <calumlind+deluge@gmail.com>2021-12-14 22:28:43 +0000
committerCalum Lind <calumlind+deluge@gmail.com>2021-12-15 09:37:55 +0000
commita03e649da6b243986d7ca4ae467be6f17558d97a (patch)
treedacbd7f1be99deb9133c81aa12d669e55523ebf2 /minify_web_js.py
parent073bbbc09df1f3aa91610b70c05406611eac3975 (diff)
downloaddeluge-a03e649da6b243986d7ca4ae467be6f17558d97a.tar.gz
deluge-a03e649da6b243986d7ca4ae467be6f17558d97a.tar.bz2
deluge-a03e649da6b243986d7ca4ae467be6f17558d97a.zip
[Build] Fix WebUI js minifying error
Some users encoutered a bug where WebUI in browser show a white screen, which indicates a problem with loading javascript files. The problem was due to closure minifying failure leaving a zero-length deluge-all.js file which broke the usual fallback mechanism to debug files. * Fixed usage of ES6 const declaration breaking closure minifying. * Cleanup minified files upon errors so no zero length files left * Replaced broken and unmaintained slimit with rjsmin. * Fixed unable to set dev or debug query args due to request args requiring bytes.
Diffstat (limited to 'minify_web_js.py')
-rwxr-xr-xminify_web_js.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/minify_web_js.py b/minify_web_js.py
index 18f2d2343..a5cd97c59 100755
--- a/minify_web_js.py
+++ b/minify_web_js.py
@@ -55,14 +55,14 @@ def minify_closure(file_in, file_out):
return False
-# Closure outputs smallest files but it is a java-based command, so have slimit
+# Closure outputs smallest files but java-based command, can use rJSmin
# as a python-only fallback.
#
-# deluge-all.js: Closure 127K, Slimit: 143K, JSMin: 162K
+# deluge-all.js: Closure 131K, rJSmin: 148K
#
if not closure_cmd:
try:
- from slimit import minify as minify
+ from rjsmin import jsmin as minify
except ImportError:
print('Warning: No minifying command found.')
minify = None
@@ -124,6 +124,8 @@ def minify_js_dir(source_dir):
print('Minifying %s' % source_dir)
if not minify_file(file_debug_js, file_minified_js):
print('Warning: Failed minifying files %s, debug only' % source_dir)
+ if os.path.isfile(file_minified_js):
+ os.remove(file_minified_js)
if __name__ == '__main__':