Skip to content

Filesystem sidebar doesn't pick up added/removed pages during dev (requires restart) #158

Description

@daveycodez

Problem

createFilesystemSidebar / createDefaultThemeFilesystemSidebar read the directory once (readdirSync), when the Vite config is evaluated. During dev, adding or removing a page under the sidebar folder never updates the sidebar — the route itself appears (the file router picks it up), but the sidebar stays stale until the dev server is manually restarted.

Feature request

Refresh the filesystem sidebar in dev when files are added/removed under the watched folder — e.g. recompute it behind a virtual module and invalidate on watcher events, or trigger a server restart from the solidbase plugin.

Workaround

A dev-only Vite plugin that restarts the server on add/unlink (edits keep normal HMR):

{
  name: "sidebar-restart",
  apply: "serve",
  configureServer(server) {
    const dir = fileURLToPath(
      new URL("./src/routes/docs/components", import.meta.url)
    )
    const onFile = (file: string) => {
      if (file.startsWith(dir) && file.endsWith(".mdx")) {
        server.restart()
      }
    }
    server.watcher.on("add", onFile)
    server.watcher.on("unlink", onFile)
  }
}

Versions: @kobalte/solidbase 0.6.9, vite 8.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions