aboutsummaryrefslogtreecommitdiff
path: root/inf/build_payload.js
diff options
context:
space:
mode:
Diffstat (limited to 'inf/build_payload.js')
-rwxr-xr-xinf/build_payload.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/inf/build_payload.js b/inf/build_payload.js
new file mode 100755
index 0000000..73a2344
--- /dev/null
+++ b/inf/build_payload.js
@@ -0,0 +1,36 @@
+#!/usr/bin/env node
+
+const fs = require("fs")
+const uglify = require("uglify-js")
+const path = require("path")
+const zlib = require("zlib");
+
+let payload_descriptor = fs.readFileSync(path.resolve(process.argv[2])).toString().split("\n");
+
+if (payload_descriptor.includes("")) payload_descriptor.pop();
+
+let full_payload = "";
+
+for (file in payload_descriptor) {
+ let fn = payload_descriptor[file];
+ let fc = fs.readFileSync(fn, "utf8");
+
+ full_payload += fc + "\n";
+}
+
+let minified = uglify.minify(
+ full_payload,
+ {
+ mangle: {
+ toplevel: true,
+ properties: {keep_quoted: true}
+ },
+ }
+).code;
+
+let compressed = zlib.brotliCompressSync(minified);
+
+console.error(`crc32: ${zlib.crc32(compressed)}`)
+
+fs.writeFileSync(process.argv[3], compressed);
+fs.writeFileSync(process.argv[4], minified); \ No newline at end of file