-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
58 lines (55 loc) · 1.52 KB
/
vite.config.ts
File metadata and controls
58 lines (55 loc) · 1.52 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import runtimeErrorOverlay from "@replit/vite-plugin-runtime-error-modal";
import react from "@vitejs/plugin-react";
import fs from 'fs';
import path from "path";
import { fileURLToPath } from "url";
import { defineConfig } from "vite";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
// Plugin to copy index.html as 404.html for GitHub Pages SPA routing
function copy404Plugin() {
return {
name: 'copy-404',
closeBundle() {
const src = path.resolve(__dirname, 'dist', 'public', 'index.html');
const dest = path.resolve(__dirname, 'dist', 'public', '404.html');
if (fs.existsSync(src)) {
fs.copyFileSync(src, dest);
console.log('✓ Copied index.html as 404.html for GitHub Pages SPA routing');
}
}
};
}
export default defineConfig({
plugins: [
react(),
runtimeErrorOverlay(),
copy404Plugin(),
...(process.env.NODE_ENV !== "production" &&
process.env.REPL_ID !== undefined
? [
await import("@replit/vite-plugin-cartographer").then((m) =>
m.cartographer(),
),
]
: []),
],
resolve: {
alias: {
"@": path.resolve(__dirname, "client", "src"),
"@shared": path.resolve(__dirname, "shared"),
"@assets": path.resolve(__dirname, "attached_assets"),
},
},
root: path.resolve(__dirname, "client"),
build: {
outDir: path.resolve(__dirname, "dist/public"),
emptyOutDir: true,
},
base: '/',
server: {
fs: {
strict: true,
deny: ["**/.*"],
},
},
});