kentcdodds / mdx-bundler

🦤 Give me MDX/TSX strings and I'll give you back a component you can render. Supports imports!
MIT License
1.78k stars 75 forks source link

handling css/scss/etc in imported components #170

Open omidantilong opened 2 years ago

omidantilong commented 2 years ago

Hi! Thanks for this great project. I've been wrestling MDX for a couple of days and arrived on this plugin earlier. It seems to do basically everything I want, but I can't figure out how to import components that import styles.

There's two things I'm encountering:

Here's the bare bones of what I'm trying to do with standard css.

# Dummy.jsx

import 'style.css' <-- plain old css

export const Dummy = () => {
return 'hello world';
}
# page.mdx

import Dummy from 'components/Dummy'

<Dummy /> <-- renders fine, but unstyled

I saw there was a similar issue but that appeared to be about css modules specifically.

Thanks! ❤️

EDIT: Yay, I've managed to get esbuild-sass-plugin to work -- but I'm now experiencing the same issue where the component renders but the styles are not included on the page 🤔

spcbfr commented 2 years ago

Hey @omidantilong this is unrelated but can I ask you where the components directory your importing from is in reference to the mdx folder ?