Skip to main content
Module

x/aleph/examples/yew-app/dev.ts

The Full-stack Framework in Deno.
Very Popular
Go to Latest
File
import { fromFileUrl } from "std/path/mod.ts";import dev, { createWatchFsEmitter } from "aleph/dev";
const emitter = createWatchFsEmitter();emitter.on("modify", ({ specifier }) => { if (specifier.endsWith(".rs")) { // rebuild the yew app then restart the dev server start(); }});
let buildProc: Deno.Process | null = null;
// build the yew app then start the dev serverasync function start() { const cwd = fromFileUrl(new URL(".", import.meta.url)); if (buildProc) { buildProc.kill("SIGTERM"); buildProc.close(); } buildProc = Deno.run({ cmd: ["wasm-pack", "build", "--target", "web"], stdout: "inherit", stderr: "inherit", cwd, }); try { await buildProc.status(); buildProc.close(); await Deno.remove(`${cwd}/pkg/.gitignore`); // start aleph dev server dev({ baseUrl: import.meta.url }); } finally { buildProc = null; }}
start();