-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.ts
47 lines (40 loc) · 1.4 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
37
38
39
40
41
42
43
44
45
46
47
/// <reference lib="deno.ns" />
import { denoPlugins } from "jsr:@luca/esbuild-deno-loader@^0.11.0";
import { build, stop } from "npm:esbuild@0.24.0";
import { copy } from "https://deno.land/std@0.210.0/fs/copy.ts";
import { emptyDir } from "https://deno.land/std@0.210.0/fs/empty_dir.ts";
import { walk } from "https://deno.land/std@0.210.0/fs/walk.ts";
async function buildIt() {
// Clean and ensure dist directory exists
await emptyDir("./dist");
// Build TypeScript
await build({
plugins: [...denoPlugins({})],
entryPoints: ["./src/main.ts"],
outfile: "./dist/main.js",
bundle: true,
minify: true,
format: "esm",
banner: {
js: `// @ts-nocheck\n// deno-lint-ignore-file`
},
platform: "browser"
}).catch((e: Error) => {
console.error('Build failed:', e);
Deno.exit(1);
});
// Copy all HTML files
for await (const entry of walk("./src", { exts: [".html"] })) {
const targetPath = entry.path.replace(/^src\//, "dist/");
await copy(entry.path, targetPath);
}
// Copy other static files
await copy("./src/styles.css", "./dist/styles.css");
await copy("./src/images", "./dist/images");
await copy("./src/ethers6.min.js", "./dist/ethers6.min.js");
console.log('Build complete! Files written to ./dist');
stop();
}
if (import.meta.main) {
buildIt();
}