Compare commits

...

1 Commits

Author SHA1 Message Date
Brooklyn Nicholson
a6d8ed484e fix(desktop): allow worktree node_modules in vite dev server
`hgui` symlinks a worktree's node_modules to the main checkout. Vite
realpaths those before enforcing server.fs.allow, so codicon/font assets
resolved outside the worktree root and 404'd — codicons silently failed
to render in any worktree dev session. Whitelist the real node_modules
locations so the fix holds from any checkout.
2026-06-06 14:32:25 -05:00

View File

@@ -2,6 +2,28 @@ import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
import path from 'path'
import fs from 'fs'
// `hgui` symlinks a worktree's node_modules to the main checkout. Vite realpaths
// those before enforcing server.fs.allow, so codicon/font assets resolve outside
// the worktree root and 404. Whitelist the real node_modules locations.
const real = (p: string): string | null => {
try {
return fs.realpathSync(p)
} catch {
return null
}
}
const fsAllow = [
...new Set(
[
path.resolve(__dirname, '../..'),
real(path.resolve(__dirname, 'node_modules')),
real(path.resolve(__dirname, '../../node_modules'))
].filter((p): p is string => p !== null)
)
]
export default defineConfig({
base: './',
@@ -34,7 +56,10 @@ export default defineConfig({
server: {
host: '127.0.0.1',
port: 5174,
strictPort: true
strictPort: true,
fs: {
allow: fsAllow
}
},
preview: {
host: '127.0.0.1',