Browse Source

Add js minification

odoacre 1 year ago
parent
commit
e303423824
1 changed files with 31 additions and 0 deletions
  1. 31 0
      build.js

+ 31 - 0
build.js

@@ -0,0 +1,31 @@
+#!/usr/bin/env node
+const swc = require('@swc/core')
+const fs = require('fs');
+const path = require('path');
+const jsdom = require("jsdom");
+const { JSDOM } = jsdom;
+
+const indexJS = fs.readFileSync("./server/public/index.js", 'utf-8');
+const indexHTML = fs.readFileSync("./server/public/index.html", 'utf-8');
+let productionCode = '';
+
+swc.transform(indexJS, {
+    // Some options cannot be specified in .swcrc
+    filename: "index.js",
+    sourceMaps: true,
+    // Input files are treated as module by default.
+    isModule: false,
+
+    // All options below can be configured via .swcrc
+    jsc: {
+        parser: {
+            syntax: "ecmascript",
+        },
+        transform: {},
+    },
+}).then((output) => {
+    productionCode = output.code;
+    // console.log(output.map); // source map (in string)
+}).then(() => {
+
+});