Skip to content

Commit 1d671c1

Browse files
committed
create: ./bin/minify.js — compress js files
1 parent e583eb1 commit 1d671c1

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

bin/minify.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { glob } from "glob";
2+
import { execSync } from "child_process";
3+
import path from "path";
4+
import fs from "fs";
5+
6+
const files = glob.sync("src/assets/js/*.js");
7+
for (const file of files) {
8+
const out = path.join("public/js", path.basename(file));
9+
fs.mkdirSync(path.dirname(out), { recursive: true });
10+
execSync(`terser "${file}" -o "${out}" -c -m`);
11+
console.log(`Minified: ${file} -> ${out}`);
12+
}

0 commit comments

Comments
 (0)