-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
astro.config.mjs
71 lines (67 loc) · 1.89 KB
/
astro.config.mjs
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
import path from "node:path";
import { fileURLToPath } from "node:url";
import { defineConfig } from "astro/config";
import purgecss from "astro-purgecss";
import react from "@astrojs/react";
import icon from "astro-icon";
import fable from "vite-plugin-fable";
const currentDir = path.dirname(fileURLToPath(import.meta.url));
const fsproj = path.join(currentDir, "src/src.fsproj");
function fsharpMiddlewarePlugin() {
return {
name: "nojaf",
configureServer(server) {
server.middlewares.use((req, res, next) => {
const isFSharpUrl = /\.fs/.test(req.url);
if (isFSharpUrl && req.url.indexOf("?import") === -1) {
req.url += "?import";
res.setHeader("Content-Type", "application/javascript");
}
return next();
});
},
handleHotUpdate: async function ({ file, server, modules }) {
if (/\.fs/.test(file) && modules && modules.length === 0) {
const module = server.moduleGraph.getModuleById(file);
if (module) {
server.ws.send({
type: "custom",
event: "hot-update-dependents",
data: [module.url],
});
return [module];
}
}
},
};
}
// https://astro.build/config
export default defineConfig({
site: "https://amplifying-fsharp.github.io",
markdown: {
gfm: true,
},
integrations: [
// Include fs extension for react-refresh
react({ include: /\.(fs|js|jsx|ts|tsx)$/ }),
icon({
include: {
bi: ["github", "linkedin", "twitter", "chevron-right"],
cil: ["speech"],
ic: ["round-live-tv"],
mdi: ["bullseye-arrow"],
"mdi-light": ["email"],
ph: ["globe-light"],
},
}),
],
vite: {
server: {
watch: {
ignored: ["**/.idea/**"],
usePolling: true,
},
},
plugins: [fsharpMiddlewarePlugin(), fable({ fsproj, jsx: "automatic" })],
},
});