This repository has been archived by the owner on Jan 20, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathastro.config.ts
75 lines (72 loc) · 1.99 KB
/
astro.config.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { defineConfig, passthroughImageService } from "astro/config";
import node from "@astrojs/node";
import { viteStaticCopy } from "vite-plugin-static-copy";
import { server as wisp } from "@mercuryworkshop/wisp-js/server";
import { baremuxPath } from "@mercuryworkshop/bare-mux/node";
import { epoxyPath } from "@mercuryworkshop/epoxy-transport";
import tailwind from "@astrojs/tailwind";
import { libcurlPath } from "@mercuryworkshop/libcurl-transport";
import { version } from "./package.json";
import { normalizePath } from "vite";
import { execSync } from "child_process";
import fs from "fs";
import path from "path";
function LU() {
const git = path.join(process.cwd(), ".git");
if (fs.existsSync(git)) {
try {
const commitDate = execSync("git log -1 --format=%cd --date=iso")
.toString()
.trim();
return JSON.stringify(new Date(commitDate).toISOString());
} catch {}
}
return JSON.stringify(new Date().toISOString());
}
export default defineConfig({
output: "server",
image: {
service: passthroughImageService(),
},
adapter: node({
mode: "middleware",
}),
integrations: [tailwind()],
vite: {
define: {
VERSION: JSON.stringify(version),
LAST_UPDATED: LU(),
},
plugins: [
{
name: "viteserver",
configureServer(server) {
server.httpServer?.on("upgrade", (req, socket, head) => {
if (req.url?.startsWith("/goo")) {
wisp.routeRequest(req, socket, head);
} else {
undefined;
}
});
},
},
viteStaticCopy({
targets: [
{
src: normalizePath(epoxyPath + "/**/*.mjs"),
dest: "ep",
overwrite: false,
},
{
src: normalizePath(baremuxPath + "/**/*.js"),
dest: "bm",
},
{
src: normalizePath(libcurlPath + "/**/*.mjs"),
dest: "lb",
},
],
}),
],
},
});