-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvite.config.ts
39 lines (35 loc) · 1.09 KB
/
vite.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
import * as dotenv from "dotenv";
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
dotenv.config();
const processEnvCanisterIds = Object.fromEntries(
Object.entries(process.env)
.filter(([key]) => key.startsWith("CANISTER_ID"))
.map(([key, value]) => [`process.env.${key}`, JSON.stringify(value)])
);
export default defineConfig({
build: {
outDir: "../../dist",
},
plugins: [react()],
root: "src/frontend",
server: {
host: "127.0.0.1",
proxy: {
// Proxy all http requests made to /api to the running dfx instance
"/api": {
target: `http://127.0.0.1:4943`,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, "/api"),
},
},
},
define: {
// Define the canister ids for the frontend to use. Currently, dfx generated
// code relies on variables being defined as process.env.CANISTER_ID_*
...processEnvCanisterIds,
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),
"process.env.DFX_NETWORK": JSON.stringify(process.env.DFX_NETWORK),
global: "globalThis",
},
});