mirror of
https://github.com/ParkerTenBroeck/automata.git
synced 2026-06-07 05:28:45 -04:00
moved to deno to bundle website
This commit is contained in:
parent
c35d7a9192
commit
7629bdab6d
28 changed files with 1534 additions and 41961 deletions
44
web/tools/build.ts
Normal file
44
web/tools/build.ts
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
import * as sass from "sass";
|
||||
|
||||
// tools/build.ts
|
||||
const ROOT = new URL("../root/", import.meta.url);
|
||||
const WASM = new URL("../wasm/", import.meta.url);
|
||||
const DIST = new URL("../dist/", import.meta.url);
|
||||
|
||||
async function run(cmd: string[], cwd?: string) {
|
||||
const p = new Deno.Command(cmd[0], { args: cmd.slice(1), cwd });
|
||||
const out = await p.output();
|
||||
if (!out.success) {
|
||||
console.error(new TextDecoder().decode(out.stderr));
|
||||
Deno.exit(out.code);
|
||||
}
|
||||
}
|
||||
|
||||
// Clean dist
|
||||
await Deno.remove(DIST, { recursive: true }).catch(() => {});
|
||||
await Deno.mkdir(DIST, { recursive: true });
|
||||
|
||||
|
||||
console.log("compiling scss...");
|
||||
|
||||
const result = sass.compile(String(new URL("style/style.scss", ROOT).pathname), {
|
||||
style: "compressed",
|
||||
});
|
||||
await Deno.writeTextFile(new URL("style.css", DIST), result.css);
|
||||
|
||||
console.log("Compiling wasm lib...");
|
||||
await run(["wasm-pack", "build", "--target", "web", "--release", "--out-dir", "wasm"], "");
|
||||
await Deno.copyFile(new URL("automata_web_bg.wasm", WASM), new URL("automata_web_bg.wasm", DIST));
|
||||
|
||||
|
||||
console.log("Compiling bundle...");
|
||||
const bundle = new Deno.Command(Deno.execPath(), {
|
||||
args: ["bundle", "--platform=browser", "--outdir", "dist", "root/index.html", "--minify",],
|
||||
});
|
||||
const bundleRes = await bundle.output();
|
||||
if (!bundleRes.success) {
|
||||
console.error(new TextDecoder().decode(bundleRes.stderr));
|
||||
Deno.exit(bundleRes.code);
|
||||
}
|
||||
|
||||
console.log("Build complete: dist/");
|
||||
Loading…
Add table
Add a link
Reference in a new issue