vite-plugin-marked
March 15, 2025 ยท View on GitHub
A minimalist Vite plugin for converting Markdown to HTML with marked. No other dependencies.
pnpm add vite-plugin-marked -D
Usage
import markedPlugin from 'vite-plugin-marked'
export default defineConfig({
plugins: [
// Default options
markedPlugin({
htmlQuery: false,
// Marked options
async: false,
breaks: false,
extensions: null,
gfm: true,
hooks: null,
pedantic: false,
renderer: null,
silent: false,
tokenizer: null,
walkTokens: null,
}),
],
})
The options for marked are documented here.
By default, any .md import will be processed into a default export containing the HTML string.
import htmlString from './example.md'
console.log(htmlString)
Note that any .md imports with ?raw or other query params won't get processed by this plugin.
?html query
You can set the htmlQuery option to true to only process .md imports with the ?html query.
import htmlString from './example.md?html'