Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handling css/scss/etc in imported components #170

Open
omidantilong opened this issue May 15, 2022 · 1 comment
Open

handling css/scss/etc in imported components #170

omidantilong opened this issue May 15, 2022 · 1 comment

Comments

@omidantilong
Copy link

omidantilong commented May 15, 2022

  • mdx-bundler version: 9.0.0
  • node version: 17
  • npm version:8.1

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:

  • For plain old non-module css, eg from a dist directory in an external component, I can set write to true and see files appearing like _mdx_bundler_entry_point-1176be25-98cc-4b47-b7b4-d23e6e10f8f9.css which has the correct styles, but they never get included. How can I get a reference to those?
  • (FIXED) For scss (in this case scss modules), esbuild errors with the "No loader is configured for ".scss" files" error. I've tried installing the necessary esbuild-sass-plugin but i'm not sure if it's possible to pass plugins/loaders into the esbuildOptions object this way? It doesn't seem to like it.

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
Copy link

spcbfr commented Sep 20, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants