Next.js component library?
Unanswered
American black bear posted this in #help-forum
American black bearOP
I have a pnpm monorepo setup with
But with this approach I have encountered a problem where the tailwindcss which I used inside these components was not working properly and I had to add this inside of my tailwindcss conifg in each app I was using
After fixing this I've noticed that
Is there a way to export my component library components with all the dependencies they need?
packages/shared-ui
. shared-ui
is a next.js app that exports it's components so I can import them as a dependency in other apps import ComponentName from "@repo/shared-ui"
// package.json
"exports": {
".": "./index.ts"
},
// index.ts
export { default as FAQ } from "~/components/common/faq/faq"
export { default as Features } from "~/components/common/features/features"
export { default as Footer } from "~/components/common/footer/footer"
// ...
But with this approach I have encountered a problem where the tailwindcss which I used inside these components was not working properly and I had to add this inside of my tailwindcss conifg in each app I was using
shared-ui
in. Manually specifying to include classes inside node_modules.// tailwind.config.ts
{
content: ["./node_modules/@repo/shared-ui/src/**/*.tsx"]
}
After fixing this I've noticed that
cn()
shadcn utility was not working inside of the exported components, which has got me thinking that I am not bundling my components correctly.Is there a way to export my component library components with all the dependencies they need?
3 Replies
Barbary Lion
Try adding this to your next.config files
const config = {
transpilePackages: [
"@repo/shared-ui"
],
}
American black bearOP
to my package or to my apps that use the package?
probably apps right?