markdown-loader for webpack using marked.
npm install markdown-loader
Since marked's output is HTML, it's best served in conjunction with the html-loader.
{
module: {
rules: [{
test: /\.md$/,
use: [
{
loader: "html-loader"
},
{
loader: "markdown-loader",
options: {
/* your options here */
}
}
]
}]
}
}
Simply pass your marked options as shown above.
In order to specify custom renderers, simply set the options.renderer
-option on your webpack options.
// webpack.config.js
const marked = require("marked");
const renderer = new marked.Renderer();
return {
module: {
rules: [{
test: /\.md$/,
use: [
{
loader: "html-loader"
},
{
loader: "markdown-loader",
options: {
pedantic: true,
renderer
}
}
]
}]
}
}