-
Notifications
You must be signed in to change notification settings - Fork 0
/
mini.js
38 lines (32 loc) · 847 Bytes
/
mini.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const { minify } = require("terser");
var fs = require("fs");
var fileName = "./assets/js/home.js";
var options = {
keep_fnames: true,
keep_classnames: true,
sourceMap: {
root: "https://quotle.dev/js",
filename: "home.js",
url: "home.js.map",
},
format: {
comments: false,
},
mangle: false,
};
(async () => {
try {
var result = await minify(
{ "home.js": fs.readFileSync(fileName, "utf8") },
options
);
console.log("Done minifying...");
fs.writeFileSync("./assets/js/home.min.js", result.code, "utf8");
fs.writeFileSync("./assets/js/home.js.map", result.map, "utf8");
console.log("Done writing...");
console.log("Done...");
} catch (err) {
const { message, filename, line, col, pos } = err;
console.log(`'${filename}':${line},${col}-- ${message}`);
}
})();