Closed marcelgruber closed 2 years ago
Looks like codehike's css is missing in prod. Do you have a link to your project?
Thanks for the quick reply! I added you as a collaborator to the repo so you can see.
Here is where I import the CSS.
Instructions for adding that was from here:
https://dev.to/anishde12020/powerful-code-blocks-with-code-hike-and-mdx-21e2
Hmm, I've used Next.js + Tailwind + Code Hike + Vercel multiple times without problems, so in theory, it should work.
I'll try to investigate when I have some time. It would help if you could try to find a minimal reproducible example.
Thank you. I'll keep hacking away. It's probably something silly.
I see the issue. I'm using postcss to purge unused CSS. There isn't a way to exclude entire imports at this time. For example, this doesn't work:
/*! purgecss start ignore */
import '@code-hike/mdx/dist/index.css'
/*! purgecss end ignore */
There's an oustanding issue for this and the feature is scheduled to be released in a later version: https://github.com/FullHuman/purgecss/issues/170
postcss does have a way to do this by specifying certain selectors to ignore, but the styles for Code Hike don't share a common ancestor class, so there isn't a way to do this reliably.
Solution 1: move the code hike dist CSS into the project and import that and wrap the CSS in ignore comments Solution 2: don't use postcss Solution 3: add a common ancestor style class in Code Hike (though this will add bloat) Solution 4: identify all parent classes in Code Hike and add them one by one to the ignore selector list in the postcss config
I chose solution 1 for now.
I think all the code hike classes start with ch-
maybe you can use that together with purgecss's whitelistPatterns
All seems to work well on my local, but when I deploy to Vercel, it doesn't work.
Local
Vercel
Inspecting Vercel
What's odd is that when I click the "tab", the code shows for a few seconds but then disappears again.
Nothing in the console indicates any issues.