-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
49 lines (46 loc) · 1.49 KB
/
Copy pathvite.config.ts
File metadata and controls
49 lines (46 loc) · 1.49 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
import path from 'node:path'
import { cloudflare } from '@cloudflare/vite-plugin'
import tailwindcss from '@tailwindcss/vite'
import react from '@vitejs/plugin-react-swc'
import { defineConfig } from 'vite'
const appPort = Number(process.env.E2E_APP_PORT ?? 6228)
const cloudflareEnv = process.env.CLOUDFLARE_ENV
export default defineConfig(({ command }) => {
const localDev = command === 'serve' && !cloudflareEnv
const disableContainers = localDev || cloudflareEnv === 'e2e'
return {
build: {
outDir: 'dist',
emptyOutDir: true,
},
plugins: [
react(),
tailwindcss(),
cloudflare({
remoteBindings: !disableContainers,
// Local console development and e2e do not need Sandbox containers.
...(disableContainers
? {
config: (config) => {
config.dev.enable_containers = false
},
}
: {}),
}),
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
'@ama/runtime-contracts': path.resolve(__dirname, './packages/runtime-contracts/src'),
'@server': path.resolve(__dirname, './server'),
'@shared': path.resolve(__dirname, './shared'),
},
},
server: {
port: appPort,
// The e2e harness assigns each run its own port; never silently drift to another one.
strictPort: process.env.E2E_APP_PORT !== undefined,
...(process.env.E2E_BASE_URL ? { allowedHosts: true as const } : {}),
},
}
})