-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdev.ts
executable file
·47 lines (41 loc) · 985 Bytes
/
dev.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
#!/usr/bin/env -S deno run -A --watch=static/,routes/
/// <reference types="./typings/twind.d.ts" />
import {
compileMdx as compile_mdx,
watchMdx as watch_mdx,
} from "https://deno.land/x/[email protected]/mod.ts";
import dev from "$fresh/dev.ts";
const precompile =
Deno.args.findLast((arg) => arg === "--precompile") !== undefined;
const watchMdxOptions: Parameters<typeof compile_mdx>[0] = {
precompile,
async compile({
compile,
source,
output,
}) {
const result = await compile(
source.value,
{
providerImportSource: null,
jsxImportSource: "preact",
jsx: true,
},
);
const value = `
// Output of \`watch_mdx\`. DO NOT EDIT.
// This file is generated automatically.
${result.value}
`;
return {
value,
output,
};
},
};
if (precompile) {
await compile_mdx(watchMdxOptions);
Deno.exit(0);
}
watch_mdx(watchMdxOptions);
await dev(import.meta.url, "./main.ts");