Skip to content

Commit

Permalink
Add recipe for loading markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
c-w committed Nov 3, 2020
1 parent ca69396 commit 436c456
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions recipes/use-markdown-loader/craco.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Import Markdown files as HTML into your React Application
// <https://github.com/peerigon/markdown-loader>

const { addBeforeLoader, loaderByName } = require('@craco/craco');

// Additional configuration for Typescript users: add `declare module '*.md'` to your `index.d.ts` file.

module.exports = {
webpack: {
configure: (webpackConfig) => {
webpackConfig.resolve.extensions.push('.md');

const markdownLoader = {
test: /\.md$/,
exclude: /node_modules/,
use: [
{
loader: require.resolve('html-loader'),
},
{
loader: require.resolve('markdown-loader'),
options: {
// see <https://marked.js.org/using_advanced#options>
},
},
],
};

addBeforeLoader(webpackConfig, loaderByName('file-loader'), markdownLoader);

return webpackConfig;
},
},
};

0 comments on commit 436c456

Please sign in to comment.