-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvite.config.js
More file actions
38 lines (37 loc) · 1.08 KB
/
vite.config.js
File metadata and controls
38 lines (37 loc) · 1.08 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
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { copyFileSync } from 'fs'
import { join } from 'path'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
{
name: 'copy-cname-and-404',
closeBundle() {
// Copy CNAME to dist after build
copyFileSync(
join(__dirname, 'public/CNAME'),
join(__dirname, 'dist/CNAME')
)
// Copy 404.html to dist (with redirect script for GitHub Pages SPA routing)
// The 404.html contains a script that redirects to index.html with the path
// encoded in the query string, which is then restored by the script in index.html
copyFileSync(
join(__dirname, 'public/404.html'),
join(__dirname, 'dist/404.html')
)
console.log('✅ CNAME and 404.html copied to dist')
}
}
],
base: '/', // GitHub Pages with custom domain
build: {
outDir: 'dist'
},
server: {
fs: {
strict: false, // Allow serving files from outside the workspace root
},
},
})