-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathcompress.mjs
More file actions
26 lines (22 loc) · 769 Bytes
/
compress.mjs
File metadata and controls
26 lines (22 loc) · 769 Bytes
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
import { readFile, writeFile } from "fs/promises";
import { minify } from "terser";
const input = await readFile("ki.js", "utf8");
const packageData = JSON.parse(await readFile("package.json", "utf8"));
const result = await minify(input, {
compress: {
unused: false, // Keep undefined aliases to reduce size
},
output: {
comments: false,
preamble: `/*!
* ${packageData.name} v${packageData.version} - ${
new Date().toISOString().split("T")[0]
}
* Copyright (c) 2015 ${packageData.author.name} (${packageData.author.url})
* License: ${packageData.license}
*/`,
},
});
await writeFile(`public/ki-${packageData.version}.min.js`, result.code);
await writeFile(`public/ki-latest.min.js`, result.code);
console.log(`Build successful!`);