removed hmr polling for localhost

This commit is contained in:
2ManyProjects 2025-04-26 00:13:46 -05:00
parent 58764c2224
commit 1d6cd19bab

View file

@ -1,9 +1,20 @@
import { defineConfig } from 'vite'; import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react'; import react from '@vitejs/plugin-react';
import path from 'path'; import path from 'path';
import dotenv from 'dotenv';
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig(({mode}) => {
// Load env variables
const env = loadEnv(mode, process.cwd(), '');
// Determine HMR host based on environment
const isProduction = process.env.ENVIRONMENT === "prod";
const hmrHost = isProduction ? 'rocks.2many.ca' : 'localhost';
const hmrConfig = isProduction
? { host: hmrHost }
: { host: hmrHost, clientPort: 3000 };
return {
plugins: [react()], plugins: [react()],
resolve: { resolve: {
alias: { alias: {
@ -35,10 +46,7 @@ export default defineConfig({
watch: { watch: {
usePolling: true, usePolling: true,
}, },
hmr: { hmr: hmrConfig
clientPort: 3000,
host: 'localhost',
}
}, },
build: { build: {
outDir: 'dist', outDir: 'dist',
@ -46,4 +54,5 @@ export default defineConfig({
emptyOutDir: true, emptyOutDir: true,
sourcemap: process.env.NODE_ENV !== 'production' sourcemap: process.env.NODE_ENV !== 'production'
} }
}
}); });