-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
33 lines (30 loc) · 984 Bytes
/
vite.config.ts
File metadata and controls
33 lines (30 loc) · 984 Bytes
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
import react from "@vitejs/plugin-react";
import { defineConfig, loadEnv } from "vite";
import topLevelAwait from "vite-plugin-top-level-await";
import wasm from "vite-plugin-wasm";
import fs from "fs";
import { resolve } from "path";
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");
const chain = env.VITE_CHAIN?.trim() || "";
const isLocal = !chain || chain === "";
// HTTPS with mkcert certs for sepolia/mainnet (WebAuthn requires trusted HTTPS)
let httpsConfig: any = false;
if (!isLocal) {
const keyPath = resolve(__dirname, "localhost-key.pem");
const certPath = resolve(__dirname, "localhost.pem");
if (fs.existsSync(keyPath) && fs.existsSync(certPath)) {
httpsConfig = {
key: fs.readFileSync(keyPath),
cert: fs.readFileSync(certPath),
};
}
}
return {
base: "./",
plugins: [react(), wasm(), topLevelAwait()],
server: {
https: httpsConfig,
},
};
});