2025-11-12 17:50:44 +01:00
|
|
|
import { defineConfig } from 'vite'
|
|
|
|
|
import react from '@vitejs/plugin-react'
|
|
|
|
|
|
2025-11-15 14:12:51 +01:00
|
|
|
// Parse allowed hosts from environment variable
|
|
|
|
|
const getAllowedHosts = () => {
|
|
|
|
|
const hosts = process.env.VITE_ALLOWED_HOSTS;
|
|
|
|
|
|
|
|
|
|
// If set to 'all', allow all hosts
|
|
|
|
|
if (hosts === 'all') {
|
|
|
|
|
return 'all';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If set, parse comma-separated list
|
|
|
|
|
if (hosts) {
|
|
|
|
|
return hosts.split(',').map(h => h.trim());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Default: localhost only
|
|
|
|
|
return ['localhost'];
|
|
|
|
|
};
|
|
|
|
|
|
2025-11-12 17:50:44 +01:00
|
|
|
// https://vite.dev/config/
|
|
|
|
|
export default defineConfig({
|
|
|
|
|
plugins: [react()],
|
|
|
|
|
server: {
|
|
|
|
|
host: '0.0.0.0',
|
|
|
|
|
port: 5173,
|
2025-11-15 14:12:51 +01:00
|
|
|
allowedHosts: getAllowedHosts(),
|
2025-11-12 17:50:44 +01:00
|
|
|
watch: {
|
|
|
|
|
usePolling: true,
|
|
|
|
|
},
|
|
|
|
|
hmr: {
|
|
|
|
|
clientPort: 8080,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
})
|