-
I'd like to display the text contents of a .scss file in an MDX file but can't seem to get it working. I tried
but neither worked. is this supported? maybe I need to add or remove a loader? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
MDX compiles to JavaScript. |
Beta Was this translation helpful? Give feedback.
-
@andyford it sounds like you are using For example, here is how CSS Modules can be included with Next+Webpack https://codesandbox.io/s/example-with-css-module-639yym?file=/pages/index.mdx The specifics of how to configure webpack to load file in the precise way you want may be something the webpack community may be able to help more in depth (https://github.com/webpack/webpack/discussions and/or https://stackoverflow.com/questions/tagged/webpack) |
Beta Was this translation helpful? Give feedback.
-
I had more moving parts coming into play here than I first thought. Thanks for the hints @wooorm and @ChristianMurphy even though I left out a lot of detail. First, this is within a Storybook project (although I don't know if that part matters much). Second, this project is already using (s)css modules (I think this turned out to be an important factor). When I was trying to include .scss files (even .scss files that did not end in .module.scss), our loaders for css modules were only looking for Here's what ended up working in my situation Added a rule to load any file with
...and then doing raw imports like:
… with that, I finally started getting raw text BUT it appeared to be the raw text after css modules had already transformed it (it wasn’t the original file contents) so to get around that, I explicitly opted out of my “normal” css loaders when the “raw” query was present:
with this webpack config, I'm now able to include arbitrary raw files 🎉 hat tip to @dcousineau who was a major help in guiding me to this solution |
Beta Was this translation helpful? Give feedback.
I had more moving parts coming into play here than I first thought. Thanks for the hints @wooorm and @ChristianMurphy even though I left out a lot of detail.
First, this is within a Storybook project (although I don't know if that part matters much). Second, this project is already using (s)css modules (I think this turned out to be an important factor).
When I was trying to include .scss files (even .scss files that did not end in .module.scss), our loaders for css modules were only looking for
*.scss
files so the file contents came back as undefined.Here's what ended up working in my situation
Added a rule to load any file with
?raw
query param as an "Asset Module"