-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
45 lines (39 loc) · 1.21 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
import react from '@vitejs/plugin-react'
import { defineConfig, loadEnv } from 'vite'
import tsconfigPaths from 'vite-tsconfig-paths'
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd(), '') }
let vocdoniEnvironment = process.env.VOCDONI_ENVIRONMENT
if (!vocdoniEnvironment) {
vocdoniEnvironment = 'stg'
}
const outDir = process.env.BUILD_PATH || 'dist'
const base = process.env.BASE_URL || '/'
let pids = []
try {
pids = JSON.parse(process.env.PROCESS_IDS)
} catch (e) {
pids = ['4ae20a8eb4caa52f5588f7bb9f3c6d6b7cf003a5b03f4589edea100000000290']
}
let demoMeta = {}
try {
demoMeta = JSON.parse(process.env.DEMO_META)
} catch (e) {
demoMeta = {
orgName: 'Test Organization',
mainTitle: 'General elections',
date: new Date().setMonth(new Date().getMonth() + 2).toString(),
}
}
return {
base,
build: { outDir },
define: {
'import.meta.env.VOCDONI_ENVIRONMENT': `"${vocdoniEnvironment}"`,
'import.meta.env.PROCESS_IDS': JSON.stringify(pids),
'import.meta.env.DEMO_META': JSON.stringify(pids),
},
plugins: [tsconfigPaths(), react()],
}
})