generated from datkat21/Pluto-TS-DevEnv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ts
36 lines (29 loc) · 1.05 KB
/
build.ts
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
import { compile } from "./lib/compileTs";
import { join } from "path";
import { watch } from "fs";
import { Glob } from "bun";
import path from "path";
export default async function build() {
const watcher = watch(
join(import.meta.dir, "./src"),
{ recursive: true },
async (event, filename) => {
console.log(`Detected ${event} in ${filename}`);
if (filename === null) return;
const glob = new Glob("*.{ts,tsx}");
const scannedFiles = await Array.fromAsync(
glob.scan({ cwd: "./src/apps" })
);
scannedFiles.forEach(async (s) => {
await compile("./src/apps/" + s, "./public/dist/apps/");
// const filePath =
// path.join("./public/dist/apps/", s.replace(".ts", "")) + ".js";
// const f = Bun.file(filePath);
// const t = await f.text();
// Bun.write(filePath, `/* Compiled from ${s} with Pluto-TS-DevEnv ${require('./package.json').version} */\n${t}`);
});
console.log("Built", scannedFiles.length, "app(s).");
}
);
console.log("Watching!");
}