react-daisyui icon indicating copy to clipboard operation
react-daisyui copied to clipboard

Using safelist /./ is too slow

Open Igosuki opened this issue 2 years ago • 4 comments

Tailwind is too slow with such a safelist pattern (advised on README.md), if I remove it I go from 2s compilation time to 300ms, and I have a 12 core processor (although I'm not sure if this is multi-threaded).

Any idea why this happens, and if we should simply add an exhaustive whitelist for daisy ?

Igosuki avatar Jun 07 '22 08:06 Igosuki

Hi @Igosuki,

You're right, it's definitely not optimal and we should reevaluate that. Can you try removing the safelist, and instead add "node_modules/daisyui/dist/**/*.js" to your content? I'm curious to see how the compilation time compares.

benjitrosch avatar Jun 08 '22 15:06 benjitrosch

Using content lookup has even better perf than safelists it seems (about 15%)

Igosuki avatar Jun 08 '22 15:06 Igosuki

I got some missing css when change to content: ['node_modules/daisyui/dist/**/*.js']. For example, "p-2" class from dropdown content is missing. image

Is this specifc case or is there something else? Sorry if issue not related.

bboyz269 avatar Jul 27 '22 04:07 bboyz269

You should also add node_modules/react-daisyui/dist/**/*.*js to content of the TailwindCSS configuration

// tailwind.config.js
module.exports = {
  content: [
    "node_modules/daisyui/dist/**/*.js",
    "node_modules/react-daisyui/dist/**/*.*js",
    ...
  ],
  ...
};

EDIT: But for some conditional classes it doesn't work (like tooltip position classes)

MrSquaare avatar Aug 21 '22 13:08 MrSquaare

You should also add node_modules/react-daisyui/dist/**/*.*js to content of the TailwindCSS configuration

This solved the issue. It didn't occur to me that react components of daisyui uses some additional classes compared to css ones.

bboyz269 avatar Oct 12 '22 09:10 bboyz269

I should add that if you are using a workspace with yarn 3, with a directory structure for instance of root/myapp you need to add ../node_modules instead of simply node_modules.

Igosuki avatar Oct 20 '22 10:10 Igosuki