-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
52 lines (45 loc) · 1.38 KB
/
vite.config.ts
File metadata and controls
52 lines (45 loc) · 1.38 KB
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
import { env } from 'node:process'
import { setTimeout } from 'node:timers/promises'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'
import tsconfigPaths from 'vite-tsconfig-paths'
const target = 'https://connect.getseam.com'
export default defineConfig(async ({ command }) => {
const isBuild = command === 'build'
const endpoint = isBuild ? target : '/api'
await setupEnv(endpoint, isBuild)
return {
base: '/examples',
envPrefix: 'SEAM_',
plugins: [tsconfigPaths(), react()],
server: {
port: 8080,
proxy: {
'/api': {
target,
rewrite: (path: string) => path.replace(/^\/api/, ''),
changeOrigin: true,
},
},
},
}
})
const setupEnv = async (endpoint: string, isBuild: boolean): Promise<void> => {
env['SEAM_ENDPOINT'] ??= endpoint
if (env['SEAM_PUBLISHABLE_KEY'] == null) {
if (!isBuild) {
// eslint-disable-next-line no-console
console.warn(
`> Using the default publishable key.
> Use your own by setting SEAM_PUBLISHABLE_KEY in your environment.
> Get one for free at https://console.seam.co/
`,
)
await setTimeout(2000)
}
env['SEAM_PUBLISHABLE_KEY'] = 'seam_pk1J0Bgui_oYEuzDhOqUzSBkrPmrNsUuKL'
}
if (env['SEAM_USER_IDENTIFIER_KEY'] == null) {
env['SEAM_USER_IDENTIFIER_KEY'] = 'f61731b1-48a3-4b61-8767-e6268c17269c'
}
}