Giter VIP home page Giter VIP logo

Comments (10)

lowv-developer avatar lowv-developer commented on July 30, 2024 6

this done the work in purgecssOptions:

whitelistPatternsChildren: [/prose$/],

from tailwindcss-typography.

RobinMalfait avatar RobinMalfait commented on July 30, 2024 4

Hey! Thank you for your bug report!
Much appreciated! 🙏

By default purge will purge everything that it can't find. Essentially if you build the markdown files, and <h2> is not present then it will remove .prose h2. If your markdown content is coming from some form database/API, then you would have to safelist all the .prose related styles (because you don't know what you will get from your DB/API).

You can use the /prose$/ regex that @lowv-developer provided.

Also see: https://tailwindcss.com/docs/optimizing-for-production#purge-css-options

from tailwindcss-typography.

oxalorg avatar oxalorg commented on July 30, 2024 2

I'm also having issues with PurgeCSS. I am only using prose and prose-xl classes in my html, but purgecss is not removing the other prose classes (sm lg 2xl) from the production build.

So my 20kb css file ends up over 120kb because of this issue.

from tailwindcss-typography.

flemay avatar flemay commented on July 30, 2024 2

I've updated my previous comment to include the dependencies. Using tailwindcss 1.5.2 still strips out classes such as .lg\:prose-lg h2 which I need to include in the whitelist.

from tailwindcss-typography.

flemay avatar flemay commented on July 30, 2024 2

Thanks, @lowv-developer! It did work! 👍

from tailwindcss-typography.

flemay avatar flemay commented on July 30, 2024

I have similar problem especially for responsive classes such as lg:prose-lg. I don't have .lg\:prose-lg h2, .lg\:prose-lg pre, etc.

I ended up having this config for tailwind.config.js:

module.exports = {
  purge: {
    mode: 'all',
    content: [
      'layouts/**/*.html'
    ],
    options: {
      whitelist: ['h2', 'pre', 'code']
    }
  },
  variants: {},
  plugins: [
    require('@tailwindcss/typography')
  ]
}

and my main.css:

/* purgecss start ignore */
@tailwind base;
@tailwind components;
/* purgecss end ignore */

@tailwind utilities;

Dependencies:

So I am wondering what is the best way to use PurgeCSS with tailwindcss-typography.

from tailwindcss-typography.

lowv-developer avatar lowv-developer commented on July 30, 2024

Typography plugin needs tailwindcss v1.50
#43

from tailwindcss-typography.

lowv-developer avatar lowv-developer commented on July 30, 2024

yeah you right, I have some issues myself with 1.5.2 and class .prose table tr
maybe the solution would be in this direction tailwindlabs/discuss#250

can we import prose somehow in the scss file so then we can do purgecss start ignore?

from tailwindcss-typography.

0x2E avatar 0x2E commented on July 30, 2024

I'm also having issues with PurgeCSS. I am only using prose and prose-xl classes in my html, but purgecss is not removing the other prose classes (sm lg 2xl) from the production build.

So my 20kb css file ends up over 120kb because of this issue.

@oxalorg You may need to manually disable unused modifiers. After I disabled all modifiers except default according to Disabling size modifiers, the file dropped from 86KB to 33KB. But this is not small enough. Chrome says that there are still 78% unused css. I suspect purgecss did not clean up @tailwindcss/typography.

from tailwindcss-typography.

huphtur avatar huphtur commented on July 30, 2024

Ran into the same problem with Eleventy, my solution was to run 11ty first and then run Tailwind:

purge settings in tailwind.config.js:

purge: {
  mode: 'all',
  content: ['_site/**/*.html'],
},

build command in package.json:

"build": "eleventy && NODE_ENV=production postcss src/css/tailwind.css --o _site/css/style.css"

The only downside (that I know so far) is that you can't inline css.

from tailwindcss-typography.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.