Load markdown files to html in webpack. Uses markdown-it and assumes nothing about your configuration.
APACHE-2.0 License
yarn add -D markdown-it-vanilla-loader
Input
# Your Markdown File
With some content.
webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.md$/,
use: [
'html-loader',
{
loader: 'markdown-it-vanilla-loader',
options: {
highlight: (code, language) => {
return language && highlightjs.getLanguage(language)
? highlightjs.highlight(language, code).value
: code;
}
}
}
]
}
]
}
};
Output
<h1>Your Markdown File</h1>
<p>With some content.</p>
This loader accepts any options that are allowed on markdown-it
, those options can be found here.
Name | Type | Default | Description |
---|---|---|---|
plugins |
{array} |
[] |
Plugins to load into markdown-it
|
plugins
Plugins can be defined in 2 ways.
webpack.config.js
{
loader: 'markdown-it-vanilla-loader',
options: {
plugins: [
// Just a string
'markdown-it-anchor',
// Array with options
[
'markdown-it-anchor',
{
permalink: true,
permalinkSymbol: '',
level: 2
}
]
]
}
}
cd example
yarn
yarn build