dan5py / turborepo-shadcn-ui

Turborepo starter with shadcn/ui pre-configured.
MIT License
466 stars 89 forks source link

Try to support Vite application and shared shadcn/ui components. #19

Closed evgenius1424 closed 4 months ago

evgenius1424 commented 7 months ago

I've added vite and copied some boilerplate. But it fails with

../../packages/ui/src/components/ui/button.tsx:5:20 - error TS2307: Cannot find module '@ui/lib/utils' or its corresponding type declarations.

5 import { cn } from "@ui/lib/utils";

If you have any ideas on how to fix it, please add comments to the review.

evgenius1424 commented 7 months ago

Hello @dan5py, I really appreciate your help with Vite support and shared components. I wanted to start some monorepo but the shadcn-ui components only worked as a local setup.

Thanks for unblocking me and possibly others.

It works great.

image
evgenius1424 commented 7 months ago

Hi @dan5py, are you planning to merge it? I think it would be a really great update for this repo to show that even different projects can share shadcn/ui components.

starkfire commented 6 months ago

+1 to this PR by @evgenius1424. I was trying to implement this template on a Turborepo project with a React.js + Vite app and I used this PR as a reference for solving the runtime issues I had when importing @ui/lib/utils (mentioned in #20).

I would just like to add though that the tsconfig.json within any Vite app should contain a path that points to the ui package itself.

"compilerOptions": {
  "paths": {
    "@ui/*": ["../../packages/ui/src/*"]
  }
}

This will also solve issues where the editor may complain about not being able to find the modules being imported.

magoz commented 6 months ago

Thank you both @evgenius1424 and @starkfire . Your combined solution works like a charm!

dan5py commented 6 months ago

Hi @dan5py, are you planning to merge it? I think it would be a really great update for this repo to show that even different projects can share shadcn/ui components.

@evgenius1424, actually I like the idea of having a clean repo with a single app as boilerplate. But yeah, this would help people with a different setup. I could create a simple docs website for it. I'll see what I can do.

evgenius1424 commented 4 months ago

Okay, I think there are projects that use turborepo with vite only. Or do some sort of migration.

If we support two major players (VIte and Next) and point out that sharing works perfectly between them, it makes a lot of sense.

rm -rf apps/vite is all you need to continue working with next only.

But yeah, it's up to you.