@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
| Subpath | Contents |
|---|---|
. | 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) andvirtual:docvia/source/browser(lazy, client code-split) from itsloadhook in dev and build alike, so nothing is written to disk for Vite to resolve.handleHotUpdatehot-swaps a.md?docviamodule on a content change and triggers a reload on a route-map change; aconfigureServerwatcher picks up added and removed files. Compile errors surface in Vite's error overlay. .md?docviatransform. Compiles each Markdown file as a module in place (through the shared core transform), so content lives once in the.mdand 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
- Framework integration: SvelteKit and plain Vite setups.
@docvia/runtime: theCompileServicethe plugin runs.