-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathvite.config.js
More file actions
38 lines (32 loc) · 1.02 KB
/
vite.config.js
File metadata and controls
38 lines (32 loc) · 1.02 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 sirv from 'sirv'
import { fileURLToPath } from 'url'
import { dirname, resolve } from 'path'
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
const docsDir = resolve(__dirname, 'public/docs')
const serveDocsPlugin = () => ({
name: 'serve-public-docs',
configureServer(server) {
const serve = sirv(docsDir, { dev: true })
server.middlewares.use((req, res, next) => {
const url = req.url
if (!url || !url.startsWith('/docs')) {
return next()
}
const parsedUrl = new URL(url, 'http://localhost')
const strippedPath = parsedUrl.pathname.slice('/docs'.length) || '/'
req.url = `${strippedPath}${parsedUrl.search}`
serve(req, res, (err) => {
req.url = url
next(err)
})
})
},
})
export default defineConfig({
plugins: [react(), serveDocsPlugin()],
homepage: "https://github.com/containers/ramalama.github.io",
base: '',
})