Skip to content
Packages

@docvia/plugin-vite

The in-process docvia() Vite plugin: virtual modules, incremental HMR, and a production module graph.

@docvia/plugin-vite integrates docvia into any Vite-based app (plain Vite or SvelteKit). The recommended export is docvia(), a single plugin that runs the CompileService in-process, so there is no separate docvia build step.

pnpm add -D @docvia/plugin-vite

Requires Node.js >=20.0.0. ESM only.

Package exports

SubpathContents
.docvia, the in-process Vite plugin.

docvia(), the in-process plugin

function docvia(config: docviaConfig, options?: DocviaVitePluginOptions): Plugin;

A single Vite plugin that owns the whole docvia integration:

  • Virtual modules. Following the Vite virtual-module convention, the plugin serves virtual:docvia/source (eager, server/SSR) and virtual:docvia/source/browser (lazy, client code-split) from its load hook in dev and build alike, so nothing is written to disk for Vite to resolve. handleHotUpdate hot-swaps a .md?docvia module on a content change and triggers a reload on a route-map change; a configureServer watcher picks up added and removed files. Compile errors surface in Vite's error overlay.
  • .md?docvia transform. Compiles each Markdown file as a module in place (through the shared core transform), so content lives once in the .md and the virtual source modules just import it.
// vite.config.ts
import { docvia } from "@docvia/plugin-vite";
import { defineConfig } from "vite";
import docviaConfig from "./docvia.config";

export default defineConfig({
  plugins: [docvia(docviaConfig)],
});

That is the complete setup. See Framework integration for the full SvelteKit walkthrough.

// A single page can also be imported directly through the ?docvia transform.
import page from "./docs/index.md?docvia";

See also