const hljs = require('highlight.js'); const pluginFactory = require('./pluginFactory'); function highlight(code, lang) { const language = hljs.getLanguage(lang) ? lang : 'plaintext'; const highlighted = hljs.highlight(code, { language }).value; return highlighted; } const withMarkdownLoader = pluginFactory((config, _options) => { config.module.rules.push({ test: /\.md$/, use: [ { loader: 'html-loader', options: { esModule: true } }, { loader: 'markdown-loader', options: { highlight } } ] }); }); module.exports = withMarkdownLoader;