Registry / web-framework / vite-plugin-markdown

vite-plugin-markdown

JSON →
library2.2.0jsnpmunverified

Vite plugin to import Markdown files as JavaScript modules, supporting Modes for Vue components, React components, HTML, and raw markdown. Current stable version 2.2.0 works with Vite >=2.0.0 (including v4 and v5). The pre-release v3.0.0 versions require Vite 5+ and are ESM-only. Key differentiators: easy integration with Vue and React, multiple import modes, TypeScript type definitions included. Actively maintained with regular updates.

npm install vite-plugin-markdown
INSTALL
IMPORT
SIG · VITE-PLUGIN-MARKDO
V
vite-plugin-markdown
web-frameworkjavascriptv2.2.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

vitePluginMarkdown
✓ import markdownPlugin from 'vite-plugin-markdown'
✗ const markdownPlugin = require('vite-plugin-markdown');
Default import is the plugin function; commonjs require works only with v2, v3 is ESM only.
Mode
✓ import { Mode } from 'vite-plugin-markdown'
✗ import { Mode } from 'vite-plugin-markdown/modes'
Mode is a named export for configuration; use enum values like Mode.HTML, Mode.VUE, Mode.REACT, Mode.MARKDOWN.
use
✓ import { use } from 'vite-plugin-markdown'
✗ import use from 'vite-plugin-markdown'
The `use` function is a named export for use with Markdown component exports (e.g., in Vue or React); available since v2.

Configures the plugin with both Vue and HTML modes, then demonstrates importing rendered HTML and frontmatter from a markdown file.

// vite.config.js import { defineConfig } from 'vite' import markdownPlugin, { Mode } from 'vite-plugin-markdown' export default defineConfig({ plugins: [ markdownPlugin({ mode: [Mode.VUE, Mode.HTML], // or Mode.REACT }), ], }) // Then in any .vue or .js file: import { html, frontmatter } from './example.md' console.log(html) // rendered HTML string console.log(frontmatter) // parsed frontmatter object // If using Mode.VUE, you can also import the Vue component: import ExampleComponent from './example.md?component' // If using Mode.MARKDOWN: import raw from './example.md?raw' // or use Mode.MARKDOWN
Debug
Known issues
breakingv3.0.0-0 requires Vite >=5 and is ESM only.
fix
Upgrade to Vite 5+; convert project to ESM or stick with v2.x if CommonJS is needed.
affects: >=3.0.0-0
deprecatedThe default export from 'vite-plugin-markdown' may change after v3 stable release.
fix
Use named imports like { Mode } or `markdownPlugin.default` for safety; refer to migration guides.
affects: >=2.0.0
gotchaMode.VUE only works if Vue plugin is installed and configured in Vite.
fix
Ensure @vitejs/plugin-vue is in your plugins and Vue is installed.
affects: >=2.0.0
gotchaImporting markdown files with `?component` suffix requires matching mode to be enabled.
fix
Include Mode.VUE in the mode array when using `?component` for Vue.
affects: >=2.0.0
Errors
Common errors & fixes
Cannot find module 'vite-plugin-markdown' or its corresponding type declarations.
Missing dependency or TypeScript not resolving types; package ships types but needs 'moduleResolution' set to 'bundler' or 'node16'.
fix
Run `npm install --save-dev vite-plugin-markdown` and ensure tsconfig.json has `"moduleResolution": "bundler"`.
The requested module 'vite-plugin-markdown' does not provide an export named 'Mode'
Using named import `{ Mode }` with a CommonJS environment that doesn't support named exports.
fix
Use default import `import markdownPlugin from 'vite-plugin-markdown'` and access `markdownPlugin.Mode`, or switch to ESM.
Error: Unsupported dynamic import: ./example.md?raw - consider using ?raw for raw markdown
Trying to import raw markdown but Mode.MARKDOWN not enabled in plugin config.
fix
Add Mode.MARKDOWN to the mode array in plugin configuration.
Upgrade
Version history
2.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
18 hits · last 30 days
node
12
OpenAI (training)
1
Resources