-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
33 lines (31 loc) · 1.16 KB
/
vite.config.ts
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
29
30
31
32
33
import { vitePlugin as remix } from "@remix-run/dev";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
import { copyFileSync } from "node:fs";
import { join } from "node:path";
export default defineConfig({
base: "/design-tools/",
plugins: [
remix({
ssr: false,
basename: "/design-tools/",
buildEnd(args) {
if (!args.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 = args.viteConfig.build.outDir;
copyFileSync(
join(buildPath, "index.html"),
join(buildPath, "404.html"),
);
},
}),
tsconfigPaths(),
],
});