Mdx: Docs: How to use MDX with create-react-app?

Created on 6 May 2018  路  5Comments  路  Source: mdx-js/mdx

Is it possible to do without ejecting?

Most helpful comment

Thanks for the quick response @timneutkens!

For anyone that finds this issue in the future:

  1. Init a project with create-react-app
  2. Install react-app-rewired (docs)
  3. Install mdx: yarn add --dev @mdx-js/loader @mdx-js/mdx
  4. Copy+paste this config-overrides.js into your project's root

And if you're using TypeScript, also:

  1. Install react-app-rewire-typescript
  2. Add it to your existing config-overrides.js (docs)
  3. Create an ambient file mdx.d.ts and include it in your tsconfig.json:

    // mdx.d.ts
    declare module '*.mdx' {
    let MDXComponent: () => JSX.Element
    export default MDXComponent
    }
    

All 5 comments

Thanks for the quick response @timneutkens!

For anyone that finds this issue in the future:

  1. Init a project with create-react-app
  2. Install react-app-rewired (docs)
  3. Install mdx: yarn add --dev @mdx-js/loader @mdx-js/mdx
  4. Copy+paste this config-overrides.js into your project's root

And if you're using TypeScript, also:

  1. Install react-app-rewire-typescript
  2. Add it to your existing config-overrides.js (docs)
  3. Create an ambient file mdx.d.ts and include it in your tsconfig.json:

    // mdx.d.ts
    declare module '*.mdx' {
    let MDXComponent: () => JSX.Element
    export default MDXComponent
    }
    

馃憤 馃憣 looks great

@bcherny do you have any updated url to the config-file?
https://github.com/mdx-js/mdx/blob/master/examples/create-react-app/config-overrides.js

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mAAdhaTTah picture mAAdhaTTah  路  4Comments

codebender828 picture codebender828  路  4Comments

waterfoul picture waterfoul  路  3Comments

dioptre picture dioptre  路  3Comments

laurieontech picture laurieontech  路  3Comments