-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
54 lines (51 loc) · 1.64 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/// <reference types="vitest" />
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
import environment from 'vite-plugin-environment';
import dotenv from 'dotenv';
dotenv.config();
const IS_DEV = process.env.DFX_NETWORK !== "ic";
const REPLICA_PORT = process.env.DFX_REPLICA_PORT ?? "4943";
export default defineConfig({
root: 'src/frontend',
build: {
outDir: '../../dist',
emptyOutDir: true,
},
optimizeDeps: {
esbuildOptions: {
define: {
global: 'globalThis',
},
},
},
server: {
proxy: {
'/api': {
target: IS_DEV ? `http://localhost:${REPLICA_PORT}` : `https://ic0.app`,
changeOrigin: true,
secure: !IS_DEV,
},
},
},
plugins: [
react(),
// Maps all envars prefixed with 'CANISTER_' to process.env.*
environment("all", { prefix: "CANISTER_" }),
// Weirdly process not available to Webworker but import.meta.env will be.
environment("all", { prefix: "CANISTER_", defineOn: 'import.meta.env' }),
// Maps all envars prefixed with 'DFX_' to process.env.*
environment("all", { prefix: "DFX_" }),
// Weirdly process not available to Webworker but import.meta.env will be.
environment("all", { prefix: "DFX_", defineOn: 'import.meta.env' }),
// Maps all envars prefixed with 'VITE_' to process.env.*
environment({ DFX_REPLICA_PORT: "4943" }),
// Weirdly process not available to Webworker but import.meta.env will be.
environment({ DFX_REPLICA_PORT: "4943" }, { defineOn: 'import.meta.env' }),
],
test: {
environment: 'jsdom',
setupFiles: 'setupTests.ts',
cache: { dir: '../node_modules/.vitest' },
},
});