Skip to content

Commit

Permalink
Merge pull request #210 from c-w/recipe-markdown-loader
Browse files Browse the repository at this point in the history
Add recipe for loading markdown
  • Loading branch information
patricklafrance authored Nov 3, 2020
2 parents ca69396 + 436c456 commit 1fea189
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 1fea189

Please sign in to comment.