Skip to content

PurgeCSS Removing MDX Styles in Nextjs Despite Being Included in Purge Content Option #3017

Answered by simonswiss
pdevito3 asked this question in Help
Discussion options

You must be logged in to vote

Hola!

I had a look at your repo shared above, and I figured out what's happening.

The prose class name, which is responsible for applying all the styles from the Typography plugin, is nowhere to be found on any of the files within ./src/**/*.*

That class is actually only present in plain text (what Purge CSS cares about) in the withProse file within the remark folder.

For that reason, purge strips out the prose class and kills all the Typography styles you rely on for the docs pages!

Your solution is to add the path to that withProse file in your purge.content array, or add prose as a purge.options.safelist value:

purge: {
  content: [
    "./src/**/*.{js,mdx}", 
+    "./remark/withProse.js"

Replies: 4 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@simonswiss
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@pdevito3
Comment options

Comment options

You must be logged in to vote
1 reply
@pdevito3
Comment options

Answer selected by simonswiss
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants