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.

Support extracting classes from any file like `@tailwindcss/jit` / `purgecss` do

See original GitHub issue

Hi!

Just trying out windicss. It seems like windicss currently only extracts classes between class="...". I use Tailwind with a variety of stacks which don’t have the same class syntax as HTML. @tailwindcss/jit and purgecss both blindly scan for anything that looks like a class and compile that. Is it possible to do that in windicss?

Example:

$ echo 'here text-red-600 are some opacity-50 classes' > a.txt
$ windicss a.txt -to a.css

a.css does not include text-red-600 or opacity-50 while @tailwindcss/jit does with the appropriate purgecss config.

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
voorjaarcommented, May 13, 2021

https://github.com/windicss/windicss/commit/4e386bbb0d3bd8e54d908790ee9b677479f96ac7 support fuzzy match.

windicss './**/*.html' './**/*.svelte' -to windi.css --watch --fuzzy --config './windi.config.js'

https://github.com/windicss/windicss/commit/c85d088c6e65a8702e5426b3e508fa6565623ee2 support extractors.

// windi.config.js
module.exports = {
  extract: {
    extractors: [
      {
        extractor: (content) => {
          return { classes: content.match(/(?<=class:)[!@\w-]+/g) ?? [] };
        },
        extensions: ['svelte'],
      },
    ],
  },
};

2reactions
voorjaarcommented, Mar 21, 2021

In the vite-plugin-windicss we are doing so. /cc @voorjaar do you think it makes sense to migrate code from the vite plugin into the core so CLI can also utilize it?

Yeah, you can migrate the part of code that extracts classNames. You can put that into utils or helpers folder.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PurgeCSS and Tailwind CSS, how to preserve responsive ...
It provides a default extractor that is working fine with a wide variety of file types, but it can be limited and does...
Read more >
Tailwind JIT and Hugo Purge issues
My current setup is purging CSS styles using the Hugo stats file. When I tried to purge the CSS using the tailwind.config.js file,...
Read more >
Extracting TailwindCSS from HTML - DevDojo
Page with inline Tailwind Classes. To extract the classes I want to use, I will first need to install the PurgeCSS CLI: npm...
Read more >
Using the Tailwindcss/jit Compiler with Phoenix - Elixir Forum
I have set up Tailwindcss for a Phoenix (v 1.5.8, so using Webpack, Liveview and Surface) project successfully and tried to switch to...
Read more >
Test driving @tailwindcss/jit. SPOILER: It's great
I've looked over them, and I'll be able to move all of them into css classes, additionally, with better mobile support. It looks...
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