Skip to content
File

Blob: worker/vite.config.ts

typescript35 lines
1import { execFileSync } from 'node:child_process';
2import { fileURLToPath } from 'node:url';
3import { defineConfig, loadEnv } from 'vite';
4import react from '@vitejs/plugin-react';
5import tailwindcss from '@tailwindcss/vite';
6import { cloudflare } from '@cloudflare/vite-plugin';
7import { liveBackend } from './dev/live-backend.ts';
8import { developmentHosts } from './dev/hosts.ts';
9import { aliases } from './dev/aliases.ts';
10 
11export default defineConfig(({ mode }) => {
12 execFileSync(
13 process.env.PYTHON ?? 'python3',
14 [
15 fileURLToPath(new URL('../scripts/prepare_secrets.py', import.meta.url)),
16 '--sync',
17 '--if-present',
18 ],
19 { stdio: ['ignore', 'ignore', 'inherit'] },
20 );
21 const env = loadEnv(mode, process.cwd(), '');
22 const allowedHosts = developmentHosts(env.RADIO_DEV_HOSTS);
23 return {
24 resolve: { alias: aliases },
25 plugins: [
26 liveBackend(env.RADIO_API_ORIGIN, allowedHosts),
27 react(),
28 tailwindcss(),
29 cloudflare({ inspectorPort: false, remoteBindings: false }),
30 ],
31 server: { host: '0.0.0.0', port: 11880, strictPort: true, allowedHosts },
32 preview: { host: '0.0.0.0', port: 11880, strictPort: true, allowedHosts },
33 };
34});