A Vite plugin that enables importing Markdoc (Stripe's Markdown-based documentation toolchain) files directly as JavaScript modules. Current stable version is 0.1.4, released as a pre-major version with no set release cadence. It uses @markdoc/markdoc under the hood to parse and transform .md files into renderable trees, which can then be rendered with Markdoc's HTML or React renderers. Key differentiators: built specifically for Vite (not Rollup/webpack), supports frontmatter, custom tags/nodes, and provides a first-class TypeScript shim for type-safe imports. Ideal for documentation sites built with Vite + React or Vue.
npm install vite-plugin-markdocVerified import paths — ran on the pinned version, not inferred.
Shows how to configure the plugin, add TypeScript shim for .md imports, and render Markdoc content as a React component.
Use Markdoc.renderers.html(content) or @markdoc/markdoc-react for React.
Pin to exact version and check changelog before upgrading.
Stay updated with package releases.
Use Vite as your build tool.
Run npm install vite-plugin-markdoc -D and add a shim file (see TypeScript Shim section).
Convert your config to ESM (use import instead of require) or use dynamic import().
Use import markdoc from 'vite-plugin-markdoc'.