-
Notifications
You must be signed in to change notification settings - Fork 71
/
app.config.ts
64 lines (60 loc) · 1.67 KB
/
app.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
import { fileURLToPath, URL } from "node:url";
import { defineConfig } from "@solidjs/start/config";
import UnoCSS from "unocss/vite";
import wasmpack from "vite-plugin-wasm-pack";
export default defineConfig({
server: {
preset: "cloudflare-pages",
rollupConfig: {
external: ["node:async_hooks"]
}
},
ssr: true,
vite: {
plugins: [UnoCSS(), wasmpack([], ["fuqr"]), blobRewriter()],
resolve: {
alias: {
// https://christopher.engineering/en/blog/lucide-icons-with-vite-dev-server/
"lucide-solid/icons": fileURLToPath(
new URL(
"./node_modules/lucide-solid/dist/source/icons",
import.meta.url
)
),
},
},
},
});
// Rewrites imports inside blobs in dev mode
function blobRewriter() {
const virtualModuleId = "virtual:blob-rewriter";
const resolvedVirtualModuleId = "\0" + virtualModuleId;
return {
name: "blob-rewriter",
resolveId(id) {
if (id === virtualModuleId) {
return resolvedVirtualModuleId;
}
},
load(id) {
if (id === resolvedVirtualModuleId) {
if (process.env.NODE_ENV !== "development") {
return "export {}";
}
return `
if (!import.meta.env.SSR) {
const originalBlob = window.Blob;
window.Blob = function(array, options) {
if (options.type === "text/javascript") {
array = array.map(item => {
return item.replace("https://qrframe.kylezhe.ng", "http://localhost:3000");
});
}
return new originalBlob(array, options);
}
}
`;
}
},
};
}