Files
krowworkforce_controltower/vite.config.js
2026-08-17 19:45:29 +05:30

57 lines
1.6 KiB
JavaScript

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
import { visualEditPlugin } from './vite-plugins/visual-edit-plugin.js'
import { errorOverlayPlugin } from './vite-plugins/error-overlay-plugin.js'
// https://vite.dev/config/
export default defineConfig(({ mode }) => {
return {
plugins: [
mode === 'development' && visualEditPlugin(),
react(),
errorOverlayPlugin(),
{
name: 'iframe-hmr',
configureServer(server) {
server.middlewares.use((req, res, next) => {
// Allow iframe embedding
res.setHeader('X-Frame-Options', 'ALLOWALL');
res.setHeader('Content-Security-Policy', "frame-ancestors *;");
next();
});
}
}
].filter(Boolean),
server: {
host: '0.0.0.0', // Bind to all interfaces for container access
port: 5174,
strictPort: true,
// Allow all hosts - essential for Modal tunnel URLs
allowedHosts: true,
watch: {
// Enable polling for better file change detection in containers
usePolling: true,
interval: 100, // Check every 100ms for responsive HMR
},
hmr: {
protocol: 'wss',
clientPort: 443
}
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
extensions: ['.mjs', '.js', '.jsx', '.ts', '.tsx', '.json']
},
optimizeDeps: {
include: ['react', 'react-dom'],
esbuildOptions: {
loader: {
'.js': 'jsx',
},
},
}
}
});