Capítulo 10 de 108
Same three paths as Next.js (shadcn/create preset, CLI scaffold, existing project) but for Vite + React, with the manual path requiring extra Vite-specific wiring: Tailwind plugin, split tsconfig alias, and vite.config.ts alias resolution.
init -t vite: CLI scaffold; add --monorepo for monorepo setup.@tailwindcss/vite: Tailwind v4 Vite plugin, installed alongside tailwindcss.tsconfig.json and tsconfig.app.json; the @/* alias must be added to both.vite.config.ts alias: needs @types/node plus a resolve.alias entry pointing @ at ./src, separate from the tsconfig paths (tsconfig is for the editor/TS, vite.config is for the bundler).npm create vite@latest
npm install tailwindcss @tailwindcss/vite
npm install -D @types/node
npx shadcn@latest init -t vite
npx shadcn@latest add button
@import "tailwindcss";
import path from "path"
import tailwindcss from "@tailwindcss/vite"
import react from "@vitejs/plugin-react"
import { defineConfig } from "vite"
export default defineConfig({
plugins: [react(), tailwindcss()],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
})
@ resolvido no bundler, não só no tsconfig.@/* alias only to tsconfig.json: Vite also needs it in tsconfig.app.json (editor resolution) and in vite.config.ts (actual bundler resolution) — all three, or imports break at build time even if the editor is happy.vite.config.ts.npm create vite@latest should use the React + TypeScript template.-c apps/web on add, import from @workspace/ui/components/*.init -t vite, add reference.