-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreact-router.config.js
28 lines (25 loc) · 971 Bytes
/
react-router.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import * as fs from 'node:fs';
import * as path from 'node:path';
/**
* @type {import('@react-router/dev/config').Config}
*/
export default {
basename: process.env.PUBLIC_BASE_PATH ?? '/',
buildEnd({ viteConfig }) {
if (!viteConfig.isProduction) {
return;
}
/**
* When deploying to GitHub Pages, if you navigate from / to another
* route and refresh the tab, it will show the default GH Pages 404
* page. This happens because GH Pages is not configured to send all
* traffic to the index.html where we can load our client-side JS.
* To fix this, we can create a 404.html file that contains the same
* content as index.html. This way, when the user refreshes the page,
* GH Pages will serve our 404.html and everything will work as expected.
*/
const buildPath = viteConfig.build.outDir;
fs.copyFileSync(path.join(buildPath, 'index.html'), path.join(buildPath, '404.html'));
},
ssr: false,
};