themesberg / flowbite

Open-source UI component library and front-end development framework based on Tailwind CSS
https://flowbite.com
MIT License
7.31k stars 710 forks source link

Tailwind CSS Next.js - Flowbite - Takes ~90 seconds to compile #743

Closed richardfwashington closed 6 months ago

richardfwashington commented 7 months ago

When following the guide here, running npm run dev results in a compilation time of ~90 seconds.

Expected behavior Compilation should be <10 seconds.

Additional context This does not occur when following the guide at the bottom of the flowbite-next-start project here

Loosetooth commented 7 months ago

My project didn't even compile at all.

I managed to fix it by changing the following lines in my tailwind.config.ts, based on the working project you linked to:

Change "./node_modules/flowbite-react/**/*.js" to "./node_modules/flowbite-react/lib/**/*.js" on the content array.

Change

plugins: [
    require("flowbite/plugin"),
  ],

to:

import flowbite from "flowbite/plugin";

...
plugins: [
    flowbite,
  ],

I'm not sure which one fixed it.

richardfwashington commented 7 months ago

The plugin changes you made I think are equivalent so that should not have made a difference. I prefer the import -> reference over require("whatever") but that is just a personal preference.

Your first change ...react/ -> ...react/lib/ will likely be the thing that allowed this to compile. It was taking SO long on my machine that it looked like it had failed.

I've created a PR for this change here -> https://github.com/themesberg/flowbite/pull/744 which fixes it.

I did afterward see another similar PR that scopes it further to the ...react/lib/esm/ folder however, I'm not sure this is necessary. Including the ...react/lib/cjs/ (aka everything in ...react/lib/**) folder is fine and makes no materially noticeable difference to the compile time.

lukasulbing commented 7 months ago

The solution provided by @richardfwashington worked for me, too! Compliation time is reduced dramatically.

zoltanszogyenyi commented 6 months ago

Fixed by @richardfwashington's PR. Thanks for contributing! <3