question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PurgeCSS skippedContentGlobs not working

See original GitHub issue

What version of Tailwind CSS are you using?

2.2.15

What build tool (or framework if it abstracts the build tool) are you using?

tailwindcss

What version of Node.js are you using?

v14.17.2

What browser are you using?

Firefox

What operating system are you using?

macOS

Reproduction repository

https://github.com/MatsKruger/tailwind-purge

Describe your issue

I have this situation where i need to exclude some folders from the build process. Earlier it would be possible with eg. !(node_modules) but it looks like that node-glob which PurgeCSS relies on, have removed this features. Instead in PurgeCSS as of 4.0.3 it is possible to use skippedContentGlobs option to define globs which should be excluded. https://github.com/FullHuman/purgecss/commit/2a276635ab598bd751a139a218f295d9923ec44b.

I have tried adding the options object to tailwind.config.js as described here https://tailwindcss.com/docs/optimizing-for-production#purge-css-options. But it is not working.

In the reproduction repository i have made 2 scripts in package.json “build” and “purge”.

Build makes a tailwind css file in the dist folder Purge purges the tailwind css file in the dist folder.

I added the same skippedContentGlobs to purgecss.config.js.

I also included the dist folder in the repository so it would be possible to see the output without building first.

The “purge” script does not work when run after “build”. That is because when using “build” the css output is invalid. It adds the below. So you would have to remove that before being able to use “purge”

.w-\[this-is\\\\\]w-\\\\\[weird-but-valid\] {
  width: this-is\\]w-\\[weird-but-valid;
}

I really hope you can help with this issue. Normally i would put everything inside a folder but in the project i am facing the issue everything is at the root level.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
RobinMalfaitcommented, Sep 12, 2021

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

jit mode doesn’t use PurgeCSS anymore so some of the features are not available. We kept the name purge for backwards compatibility reasons.

Looking at your repo, instead of defining your content as:

content: [
  './**/*.php',
  './**/*.js',
],

I would define it more explicit so that you don’t need the skippedContentGlobs at all. For example, you could put everything in a src folder:

content: [
  './src/**/*.{php,js}',
],
0reactions
vchirikovcommented, Dec 7, 2021

Faced with the same issue 😦 Sad that we don’t have ignore globs

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration - PurgeCSS
Pass an array of globs matching items that should be excluded. (Note: this option has no effect if content is not globs.) skippedContentGlobs:...
Read more >
@fullhuman/postcss-purgecss - npm
PostCSS plugin for PurgeCSS. Latest version: 5.0.0, last published: 3 months ago. Start using @fullhuman/postcss-purgecss in your project by ...
Read more >
purgecss | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
PurgeCSS: Remove unused CSS code - LogRocket Blog
Unused code can result in a larger file size, harm performance, make it easy to lose track of each item, and cause optimization...
Read more >
purgecss: Versions - Openbase
Bug Fixes. add safelist variables to postcss-purgecss #840 (c822058); gulp-purgecss: support skippedContentGlobs option #853 (b72de77); Purgecss webpack ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found