Fix build and minify html and js

This commit is contained in:
Scott Shawcroft 2022-07-12 11:13:17 -07:00
parent 425a0efeca
commit 15fe386457
No known key found for this signature in database
GPG Key ID: 0DFD512649C052DA
4 changed files with 14 additions and 0 deletions

View File

@ -5,6 +5,7 @@
.. module:: hashlib
:synopsis: hashing algorithms
:noindex:
|see_cpython_module| :mod:`cpython:hashlib`.

View File

@ -26,3 +26,7 @@ pyelftools
# for stubs and annotations
adafruit-circuitpython-typing
# for web workflow minify
minify_html
jsmin

View File

@ -26,6 +26,9 @@
#include "supervisor/shared/web_workflow/websocket.h"
// TODO: Remove ESP specific stuff. For now, it is useful as we refine the server.
#include "esp_log.h"
typedef struct {
socketpool_socket_obj_t socket;
uint8_t opcode;

View File

@ -4,6 +4,8 @@
import argparse
import gzip
import minify_html
import jsmin
import mimetypes
import pathlib
@ -24,6 +26,10 @@ for f in args.files:
variable = path.name.replace(".", "_")
uncompressed = f.read()
ulen = len(uncompressed)
if f.name.endswith(".html"):
uncompressed = minify_html.minify(uncompressed.decode("utf-8")).encode("utf-8")
elif f.name.endswith(".js"):
uncompressed = jsmin.jsmin(uncompressed.decode("utf-8")).encode("utf-8")
compressed = gzip.compress(uncompressed)
clen = len(compressed)
compressed = ", ".join([hex(x) for x in compressed])