Skip to content

Commit 326034e

Browse files
authored
Merge pull request #30 from hcp-uw/website-routing-fix
Fix website routing issues
2 parents 780cf07 + b32bb9f commit 326034e

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"update-types": "npx supabase gen types --lang=typescript --project-id \"$PROJECT_REF\" > src/database.types.ts",
88
"dev": "vite",
99
"build": "CI=false && tsc -b && vite build",
10-
"build-for-vergil": "cross-env BUILD_FOR_VERGIL=true && tsc -b && vite build",
10+
"build-for-vergil": "cross-env BUILD_FOR_VERGIL=true && tsc -b && vite build --mode vergil",
1111
"serve": "vite preview",
1212
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
1313
"preview": "vite preview",
@@ -55,4 +55,4 @@
5555
"vite": "^5.3.4",
5656
"vite-plugin-singlefile": "^2.0.2"
5757
}
58-
}
58+
}

src/App.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ChakraProvider } from '@chakra-ui/react';
2-
import { HashRouter as Router, Route, Routes } from 'react-router-dom';
2+
import { HashRouter, BrowserRouter, Route, Routes } from 'react-router-dom';
33
import { MembersPage } from './pages/MembersPage';
44
import { LeadTeamsPage } from './pages/LeadTeamsPage';
55
import { ProjectTeamsPage } from './pages/ProjectTeamsPage';
@@ -13,6 +13,8 @@ import Layout from './components/Layout';
1313
import theme from './theme';
1414
import LandingPage from './pages/LandingPage';
1515

16+
const Router = import.meta.env.VITE_USE_HASH_ROUTER ? HashRouter : BrowserRouter;
17+
1618
function App() {
1719
return (
1820
<ChakraProvider theme={theme}>

vercel.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"rewrites": [
3+
{
4+
"source": "/(.*)",
5+
"destination": "/"
6+
}
7+
]
8+
}

vite.config.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@ import tailwindcss from '@tailwindcss/vite'
66
let plugins = [react(), viteSingleFile()]
77

88
// https://vitejs.dev/config/
9-
export default defineConfig({
10-
plugins: [
11-
tailwindcss(),
12-
],
13-
base: '/'
14-
})
9+
export default defineConfig(({ mode }) => {
10+
const isVergil = mode === 'vergil';
11+
12+
return {
13+
plugins: [
14+
tailwindcss(),
15+
],
16+
base: isVergil ? '/hcpuw/' : '/',
17+
define: {
18+
'import.meta.env.VITE_USE_HASH_ROUTER': isVergil,
19+
},
20+
};
21+
})

0 commit comments

Comments
 (0)