fixed localhost polling

This commit is contained in:
2ManyProjects 2025-04-26 00:49:18 -05:00
parent 3bde132b49
commit e597f1caa6
3 changed files with 62 additions and 40 deletions

View file

@ -18,6 +18,7 @@
"@tanstack/react-query-devtools": "^5.12.2", "@tanstack/react-query-devtools": "^5.12.2",
"axios": "^1.6.2", "axios": "^1.6.2",
"date-fns": "^4.1.0", "date-fns": "^4.1.0",
"dotenv": "^16.5.0",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-redux": "^9.0.2", "react-redux": "^9.0.2",
@ -2657,6 +2658,17 @@
"csstype": "^3.0.2" "csstype": "^3.0.2"
} }
}, },
"node_modules/dotenv": {
"version": "16.5.0",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.5.0.tgz",
"integrity": "sha512-m/C+AwOAr9/W1UOIZUo232ejMNnJAJtYQjUbHoNTBNTJSvqzzDh7vnrei3o3r3m9blf6ZoDkvcw0VmozNRFJxg==",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://dotenvx.com"
}
},
"node_modules/dunder-proto": { "node_modules/dunder-proto": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",

View file

@ -20,6 +20,7 @@
"@tanstack/react-query-devtools": "^5.12.2", "@tanstack/react-query-devtools": "^5.12.2",
"axios": "^1.6.2", "axios": "^1.6.2",
"date-fns": "^4.1.0", "date-fns": "^4.1.0",
"dotenv": "^16.5.0",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-redux": "^9.0.2", "react-redux": "^9.0.2",

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}) => {
dotenv.config();
// Load env variables
// 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'
} }
}
}); });