Skip to content

Commit 5c49fa6

Browse files
authored
feat: js — compress/minify dev and prod files (#277)
feat: `js` — compress/minify dev and prod files
2 parents e583eb1 + 7aa03dc commit 5c49fa6

File tree

4 files changed

+501
-11
lines changed

4 files changed

+501
-11
lines changed

.eleventy.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ export default function (eleventyConfig) {
6363
eleventyConfig.addPassthroughCopy({
6464
"src/assets/*.pdf": "assets",
6565
"src/assets/images": "images",
66-
"src/assets/js/*": "js",
6766
"src/admin/*": "admin",
6867
"settings.json": "settings.json",
6968
"src/robots.txt": "robots.txt"

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)