Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for workspaces with flowbite.content() #1497

Open
sughodke opened this issue Oct 4, 2024 · 4 comments
Open

Support for workspaces with flowbite.content() #1497

sughodke opened this issue Oct 4, 2024 · 4 comments

Comments

@sughodke
Copy link

sughodke commented Oct 4, 2024

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.

flowbite.content({ base: "../../" }),

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');
}
@SutuSebastian
Copy link
Collaborator

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/*).

flowbite.content({ base: "../../" }),

We'll think of a better API in the future for configuring paths for monorepo structures.

@sughodke
Copy link
Author

sughodke commented Oct 4, 2024

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?

@SutuSebastian
Copy link
Collaborator

SutuSebastian commented Oct 8, 2024

@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

@SutuSebastian
Copy link
Collaborator

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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants