Support for workspaces with flowbite.content()
As the below line from this very repo shows, flowbite.content() returns a path assuming you are running flowbite in a standalone repo. But if you are using flowbite in monorepo, this assumption is not valid and the path returned by flowbite.content() is incorrect. The build (via npm run build) works as expected, but the resultant CSS artifacts don't contain all the CSS.
https://github.com/themesberg/flowbite-react/blob/bed3c41eb3291430db424b2e37233659507e1581/apps/web/tailwind.config.cjs#L11
I propose within flowbite.content() we use require.resolve() to correctly find the node_modules directory to avoid this guessing.
import path from 'path';
export function content( ... ) {
const flowbiteDir = path.dirname(
require.resolve('flowbite-react/package.json', { paths: [__dirname] })
);
return path.join(flowbiteDir, 'dist/esm/**/*.mjs');
}
The below line u are referring to is exactly configured to be used within a monorepo (in this very monorepo structure) where node_modules are to be found 2 levels out from the directory its being used (apps/web/*).
https://github.com/themesberg/flowbite-react/blob/bed3c41eb3291430db424b2e37233659507e1581/apps/web/tailwind.config.cjs#L11
We'll think of a better API in the future for configuring paths for monorepo structures.
node_modules are to be found 2 levels out from the directory
Why not have it auto-configured? Avoid shooting yourself in the foot, and guessing where the right directory is.
We'll think of a better API in the future for configuring paths for monorepo structures.
Eager to learn more, what did you have in mind?
@sughodke u can't really have it "auto-configured" due to the vast ways of using and configuring monorepo's, it's almost impossible to auto detect where the package is installed, thats why we're considering to pre-compile and extract all classNames used in the package (per component too), and feed those to tailwind.config.js, but keep in mind this is experimental for now and it might change.
Also, this is why flowbite.content() accepts an options param which has base as an overridable, giving u access to hoist in the correct directory the node_modules path
Why not have it auto-configured? Avoid shooting yourself in the foot, and guessing where the right directory is.
That's the point, we're not, we know exactly where the packages are being installed, since we configured the monorepo, so there's no "guessing".
Solved by the #1498