-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
71 lines (63 loc) · 2.04 KB
/
Copy pathvite.config.ts
File metadata and controls
71 lines (63 loc) · 2.04 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
67
68
69
70
71
import { sites } from '@openai/sites-vite-plugin';
import tailwindcss from '@tailwindcss/postcss';
import vinext from 'vinext';
import { defineConfig } from 'vite';
import fs from 'node:fs';
let hostingConfig: { d1?: string | null; r2?: string | null } = { d1: null, r2: null };
try {
if (fs.existsSync('./.openai/hosting.json')) {
hostingConfig = JSON.parse(fs.readFileSync('./.openai/hosting.json', 'utf8'));
}
} catch {
// Graceful fallback
}
const SITE_CREATOR_PLACEHOLDER_DATABASE_ID =
'00000000-0000-4000-8000-000000000000';
const d1 = hostingConfig?.d1 ?? null;
const r2 = hostingConfig?.r2 ?? null;
// 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: isCodexSeatbeltSandbox
? { watch: { useFsEvents: false, usePolling: true } }
: undefined,
plugins: [
vinext(),
sites(),
cloudflare({
viteEnvironment: { name: 'rsc', childEnvironments: ['ssr'] },
config: localBindingConfig,
}),
],
};
});