-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
66 lines (59 loc) · 1.85 KB
/
Copy pathvite.config.ts
File metadata and controls
66 lines (59 loc) · 1.85 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { sites } from '@openai/sites-vite-plugin';
import tailwindcss from '@tailwindcss/postcss';
import vinext from 'vinext';
import { defineConfig } from 'vite';
import hostingConfig from './.openai/hosting.json';
const SITE_CREATOR_PLACEHOLDER_DATABASE_ID =
'00000000-0000-4000-8000-000000000000';
const { d1, r2 } = hostingConfig;
// macOS Seatbelt blocks FSEvents, so Codex previews need polling for HMR.
const isCodexSeatbeltSandbox = process.env.CODEX_SANDBOX === 'seatbelt';
const localBindingConfig = {
main: 'vinext/server/app-router-entry',
compatibility_flags: ['nodejs_compat'],
d1_databases: d1
? [
{
binding: d1,
database_name: 'site-creator-d1',
database_id: SITE_CREATOR_PLACEHOLDER_DATABASE_ID,
},
]
: [],
r2_buckets: r2
? [
{
binding: r2,
bucket_name: 'site-creator-r2',
},
]
: [],
};
export default defineConfig(async () => {
// Keep Wrangler and Miniflare state project-local. These are non-secret tool
// settings; application environment belongs in ignored `.env*` files.
process.env.WRANGLER_WRITE_LOGS ??= 'false';
process.env.WRANGLER_LOG_PATH ??= '.wrangler/logs';
process.env.MINIFLARE_REGISTRY_PATH ??= '.wrangler/registry';
// Wrangler snapshots its log path while the Cloudflare plugin is imported.
const { cloudflare } = await import('@cloudflare/vite-plugin');
return {
css: { postcss: { plugins: [tailwindcss()] } },
server: {
host: '127.0.0.1',
port: 3000,
strictPort: true,
...(isCodexSeatbeltSandbox
? { watch: { useFsEvents: false, usePolling: true } }
: {}),
},
plugins: [
vinext(),
sites(),
cloudflare({
viteEnvironment: { name: 'rsc', childEnvironments: ['ssr'] },
config: localBindingConfig,
}),
],
};
});