-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcompile.js
37 lines (34 loc) · 1.09 KB
/
compile.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
const { exec } = require("child_process");
function command(cmd) {
return new Promise(function(ok, fail) {
exec(cmd, (error, stdout, stderr) => {
if (error) {
console.log(error.message);
fail();
return;
}
if (stderr) {
console.log(stderr);
fail();
return;
}
console.log(stdout);
ok();
});
});
}
(async() => {
try {
await command("npx webpack");
(async() => {
await command("npx babel src/lang --out-dir dist/lang");
await command("npx terser-folder dist/lang -o dist/lang -e -x .js"); // important, minifty utf-8, use terser-folder
})();
(async() => {
await command("npx babel dist/static/bundle.js -o dist/static/bundle.js --minified --no-comments --no-highlight-code");
await command("npx terser dist/static/bundle.js -o dist/static/bundle.js");
})();
} catch (error) {
console.log("Compilation failed");
}
})();