Using mdx in @next
See original GitHub issueI think many CRA users like myself are using mdx-js/mdx
. The mdx docs for CRA setup
use create-react-app-rewired
, but I’ve managed just fine in CRA v1.x without ejecting or rewiring by inlining webpack loader and eslint overrides:
/* eslint-disable import/no-webpack-loader-syntax */
import Content from '!babel-loader!@mdx-js/loader!./Content.mdx';
I tried the same course of action in @2.0.0
but its not working for reasons I haven’t looked into yet. (I’ll leave details in a comment below. Raising at mdx-js
may be appropriate.)
THE REASON I’m submitting this issue is to identify MDX usage as a likely reason for ejecting/rewiring in response to @Timer’s comment https://github.com/timarney/react-app-rewired/issues/162#issuecomment-418708200. The future support outlook for rewired and missing workaround for CRA@next is unfortunate for MDX users.
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Advanced Features: Using MDX - Next.js
MDX is a superset of markdown that lets you write JSX directly in your markdown files. It is a powerful way to add...
Read more >Create a Next.js and MDX blog - LogRocket Blog
Learn how to build a blog in Next.js using MDX to allow for the creation of interactive content, along with adding styles and...
Read more >Building a Blog With Next.js and MDX | The WebStorm Blog
We're going to learn about Next.js and MDX by building a blog. We'll learn how to set up Next.js apps, generate dynamic URLs,...
Read more >How to setup MDX in Next.js - jmagrippis
The library we'll be using is next-mdx-enhanced. It is not the official plugin by the Nextjs team, which is workable but has you...
Read more >How to Build Your Own Blog with Next.js and MDX
next -mdx-remote does the background compilation of the MDX files by allowing them to be loaded within Next.js' getStaticProps or ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
One issue with supporting MDX in the same way that SCSS is supported is that it’s rare that you’ll want to use vanilla MDX. At minimum, you’re probably going to want to add plugins to improve typography, add emoji support, and handle front matter – but you can go further and do things like add
id
props to titles for deep linking, generate a table of contents, etc.I’ve tried putting together an MDX macro with all this, but can’t find a way to get recompile-on-save working, which is a bummer.
I do have MDX working with CRA@2 though, using
import('!babel-loader!mdx-loader!./tutorial/make-a-blog.md')
and the following.babelrc
:Even if this isn’t supported, I feel like it’s probably the most pragmatic approach atm.
We should ask for a
@mdx-js/macro
ormdx.macro
package!