Skip to content

Instantly share code, notes, and snippets.

@dfee
Created August 30, 2018 22:03
Show Gist options
  • Save dfee/d8d283c3e805b667a43b5d221d1a6fce to your computer and use it in GitHub Desktop.
Save dfee/d8d283c3e805b667a43b5d221d1a6fce to your computer and use it in GitHub Desktop.
const marked = require("marked");
module.exports = (nextConfig = {}) => {
return Object.assign({}, nextConfig, {
webpack(config, options) {
config.module.rules.push({
test: /\.(html)$/,
use: {
loader: "html-loader",
options: {
attrs: [":data-src"]
}
}
});
config.module.rules.push({
test: /\.md$/,
use: [
{ loader: "html-loader" },
{
loader: "markdown-loader",
options: { pedantic: true, renderer: new marked.Renderer() }
}
]
});
if (typeof nextConfig.webpack === "function") {
return nextConfig.webpack(config, options);
}
return config;
}
});
};
@mrcoles
Copy link

mrcoles commented Oct 16, 2018

Hi, I was about to write one of these then found this. I found this other example https://stackoverflow.com/a/52280005/376489 too, but could you share what the first html-loader rule with the ":data-src" option does here?

edit: nm, I think I’m going to use https://github.com/zeit/next-plugins/tree/master/packages/next-mdx instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment