Add HMR Injection

This commit is contained in:
Matt DiMeglio 2025-06-12 09:57:08 -04:00
parent a2ce912ee8
commit 9053ca0b44
3 changed files with 19 additions and 34 deletions

View file

@ -6,6 +6,7 @@
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=WDXL+Lubrifont+TC&display=swap" rel="stylesheet">
<script src="public/hmr-runtime-inject.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ShiftSync</title>
</head>

View file

@ -0,0 +1,5 @@
window.__vite_plugin_hmrOptions = {
protocol: location.protocol === 'https:' ? 'wss' : 'ws',
host: location.hostname,
port: location.port || (location.protocol === 'https:' ? 443 : 80),
};

View file

@ -3,33 +3,13 @@ import react from '@vitejs/plugin-react';
import path from 'path';
// https://vite.dev/config/
export default defineConfig(({ mode = 'local' }) => {
const isDev = mode === 'dev';
const isProd = mode === 'prod';
return {
export default defineConfig({
plugins: [react()],
server:{
host: true,
allowedHosts: true,
cors: true,
hmr: isDev
? {
protocol: 'wss',
host: 'shift-dev.code-catalyst.com',
clientPort: 443,
}
: isProd ?
{
protocol: 'wss',
host: 'shift.code-catalyst.com',
clientPort: 443,
}
: {
protocol: 'wss',
host: 'localhost',
clientPort: 443,
},
hmr: true
},
resolve: {
alias: {
@ -37,5 +17,4 @@ export default defineConfig(({ mode = 'local' }) => {
'@components': path.resolve(__dirname, 'components')
},
},
}
});