Add js minification

This commit is contained in:
odoacre 2022-11-07 16:50:11 +01:00
parent d988b14f57
commit e303423824

31
build.js Normal file
View file

@ -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(() => {
});