Registry / web-framework / vite-plugin-md-to-html

vite-plugin-md-to-html

JSON →
library0.0.18jsnpmunverified

Vite plugin to convert Markdown files to HTML strings at build time, with front-matter extraction, optional syntax highlighting via highlight.js, and relative image path resolution. Version 0.0.18 is the latest stable release, with monthly updates. Differentiators: zero-config setup for plain HTML output (no framework coupling), built-in image resolution for Vite asset handling, and optional build-time syntax highlighting. Targets developers using Vite who want to import .md files as HTML strings without a frontend framework.

npm install vite-plugin-md-to-html
INSTALL
IMPORT
SIG · VITE-PLUGIN-MD-TO-
V
vite-plugin-md-to-html
web-frameworkjavascriptv0.0.18
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

vitePluginMdToHTML
import { vitePluginMdToHTML } from 'vite-plugin-md-to-html'
import vitePluginMdToHTML from 'vite-plugin-md-to-html'
Named export, not default. TypeScript types are included.
attributes
import { attributes } from './test.md'
import attributes from './test.md'
attributes is a named export from the compiled markdown module. Default export is the HTML string.
PluginOptions
import type { PluginOptions } from 'vite-plugin-md-to-html'
TypeScript only; available since v0.0.14.

Shows Vite plugin setup with image resolution and syntax highlighting, plus importing .md to get HTML string and frontmatter attributes.

// vite.config.ts import { defineConfig } from 'vite'; import { vitePluginMdToHTML } from 'vite-plugin-md-to-html'; export default defineConfig({ plugins: [ vitePluginMdToHTML({ resolveImageLinks: true, syntaxHighlighting: true }) ] }); // src/main.ts import html, { attributes } from './test.md'; document.title = attributes.title ?? ''; document.querySelector('#app')!.innerHTML = html; type Frontmatter = { title?: string; // ... other fields };
Debug
Known issues
breakingIn versions before v0.0.14, image path resolution only worked in CSR, not SSR/SSG.
fix
Upgrade to v0.0.14 or later for SSR/SSG support.
affects: <0.0.14
deprecatedThe option 'markdownIt' is passed through to markdown-it but is not officially typed in PluginOptions until later versions.
fix
Use the 'markdownIt' option and ensure you have the correct type definitions.
affects: <0.0.11
gotchaImages in markdown are not resolved by default; you must enable 'resolveImageLinks' option.
fix
Set resolveImageLinks: true in plugin options.
affects: >=0.0.0
gotchaSyntax highlighting CSS is not included; you must import a highlight.js stylesheet separately.
fix
import 'highlight.js/styles/github.css';
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module './test.md' or its corresponding type declarations.
TypeScript cannot resolve .md imports without a type declaration.
fix
Add `/// <reference types='vite-plugin-md-to-html/types' />` to a global.d.ts file.
[vite] Internal server error: Failed to parse source for import analysis because the content contains invalid JS syntax.
Vite fails to parse .md file if the plugin is not properly configured in config.
fix
Ensure the plugin is added to the vite.config.js/ts plugins array.
Uncaught TypeError: Failed to resolve module specifier 'vite-plugin-md-to-html'. Relative references must start with either '/', './', or '../'.
The package is not installed or not imported correctly.
fix
Run `npm install --save-dev vite-plugin-md-to-html` and verify import path.
Upgrade
Version history
0.0.18latest on npm
Audit
Dependencies
viterequiredpeer dependency; plugin only works with Vite
markdown-itrequiredcore markdown parser used internally
highlight.jsoptionalused for syntax highlighting when option enabled
Agent activity
6 hits · last 30 days
node
4
Amazon
1
OpenAI (training)
1
Resources
vite-plugin-md-to-html — npm install vite-plugin-md-to-html · libregistry