Add js minification
This commit is contained in:
parent
d988b14f57
commit
e303423824
1 changed files with 31 additions and 0 deletions
31
build.js
Normal file
31
build.js
Normal 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(() => {
|
||||
|
||||
});
|
Loading…
Reference in a new issue