Steps to create your own project:
- 
npx create-react-app mdx-js-test(replacemdx-js-testwith your project's name)
- 
npm install @mdx-js/loader @mdx-js/mdx craco @jackwilsdon/craco-use-babelrc
- 
./craco.config.js:const BabelRcPlugin = require("@jackwilsdon/craco-use-babelrc"); module.exports = { plugins: [{ plugin: BabelRcPlugin }], webpack: { configure: webpackConfig => { const oneOfRules = webpackConfig.module.rules.find(x => !!x.oneOf).oneOf; oneOfRules.unshift({ test: /\.mdx?$/, use: ["babel-loader", "@mdx-js/loader"] }); webpackConfig.node.fs = "empty"; return webpackConfig; } } };
- 
./src/index.js:import React from "react"; import ReactDOM from "react-dom"; import Hello from "./hello.mdx"; import "./index.css"; import * as serviceWorker from "./serviceWorker"; ReactDOM.render(<Hello />, document.getElementById("root")); // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: https://bit.ly/CRA-PWA serviceWorker.unregister();
- 
./src/hello.mdx:# Hello, MDX! This is an example using Create React App + craco
- 
./.babelrc:{ "presets": [ [ "@babel/env", { "corejs": 2, "useBuiltIns": "usage" } ], "@babel/react" ], "plugins": ["macros"] }
- 
npm start
You should see:
This is an exmaple using Create React App + craco