Skip to content

Commit

Permalink
feat: single page fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bodobraegger committed Jul 25, 2024
1 parent 67b21f7 commit 0551d2d
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
21 changes: 21 additions & 0 deletions 404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8" />

<title>SGHPA Demo</title>

<script>
sessionStorage.redirect = location.href;
</script>

<meta http-equiv="refresh" content="0;URL='/thilo'" />
</head>

<body>
redirecting...
</body>


</html>
10 changes: 10 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@
BACKEND_URL: '${BACKEND_URL}',
};
</script>
<script>
(function(){
var redirect = sessionStorage.redirect;
delete sessionStorage.redirect;
if (redirect && redirect != location.href) {
history.replaceState(null, null, redirect);
console.log('Redirecting to', redirect);
}
})();
</script>
<script defer type="module" src="/src/index.tsx"></script>
</head>
<body data-light-theme="light" data-dark-theme="dark" data-color-mode="auto">
Expand Down
22 changes: 21 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import sass from 'sass'

export default defineConfig({
build: {
outDir: 'build'
outDir: 'build',
rollupOptions: {
input: entryPoints(
"index.html",
"404.html",
)
}
},
base: process.env.REACT_APP_PUBLIC_URL,
plugins: [react(),
Expand All @@ -21,3 +27,17 @@ export default defineConfig({
},
},
});

import { join, parse, resolve } from "path";

function entryPoints(...paths) {
const entries = paths.map(parse).map(entry => {
const { dir, base, name, ext } = entry;
const key = join(dir, name);
const path = resolve(__dirname, dir, base);
return [key, path];
});

const config = Object.fromEntries(entries);
return config;
}

0 comments on commit 0551d2d

Please sign in to comment.