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.

Can't disable CSS purging

See original GitHub issue

Hi!

I’m trying to disable CSS purging during development. I’m using the Chromium developer tools as a sort of WYSIWYG editor. The list of suggestions in the image below is populated with all the available CSS classes. Purging naturally strips that list down to those classes that are actually in the markup/code. Since this is for playing around with styling I haven’t added to the files yet, I would need an unpurged version.

devtools

I’ve tried to simply set purge: false in the tailwind.config.js, but that gets me the webpack error

error - ./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[2].oneOf[9].use[1]!./node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[2].oneOf[9].use[2]!./src/styles/main.css
TypeError: Cannot read properties of undefined (reading 'filter')

Setting purge: [] just removes all classes.

The object declaration

purge: {
    enabled: false,
    content: ['./src/**/*.{js,ts,jsx,tsx}'],
  },

behaves like using an Array, where everything is stripped when content is a filter that finds nothing (e.g. empty). enabled is completely ignored. So is the NODE_ENV variable. Accodring to the tailwind documentation (last paragraph), purging should in general only happen when NODE_ENV === 'production'. Checking directly in tailwind.config.js shows NODE_ENV === 'development', though.

Any ideas how I can disable purgin at all, when NODE_ENV === 'development'?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
ixartzcommented, Dec 4, 2021

Yes, I have tried on my computer and it works perfectly. Exactly what you have in your screenshot.

Maybe it’s related to the Next JS cache. You need to delete .next folder in your project to make it work.

0reactions
ixartzcommented, Dec 4, 2021

No problem, I also have been tricked several time by the .next cache. 🥲

Great! It helps.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to disable purging in Tailwind 3? #6557 - GitHub
After upgrading to Tailwind 3, I would like to continue to be able to experiment locally in the browser with various CSS classes,...
Read more >
Disable purging of unused CSS in svelte - Stack Overflow
I'm working with webcomponents and sub-components aren't styled if svelte purges the unused selectors. I hope there is a setting i can configure ......
Read more >
PurgeCSS: Remove unused CSS code - LogRocket Blog
In this tutorial, we'll explore PurgeCSS, a tool for removing unused CSS code. With PurgeCSS as a part of our development workflow, we...
Read more >
How Do You Remove Unused CSS From a Site?
To clean CSS with multiple pages just use that tool for all pages with different layouts. Then merge all exported CSS files to...
Read more >
4 Ways to Remove Unused CSS - Bits and Pieces
4 Ways to Remove Unused CSS · 1. PurgeCss · 2. PurifyCSS · 3. uncss · 4. Coverage Tab in Chrome DevTools (Manually)....
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