This is Frontend Monorepo built with Turborepo with Tailwind CSS and Next.js.
.
βββ apps
β βββ admin
β β βββ app
β β βββ public
β βββ client
β βββ app
β βββ public
βββ packages
βββ eslint-config
βββ tailwind-config
βββ typescript-config
βββ ui
βββ srcμ΄ νλ‘μ νΈλ Node.js
v22.16.0(LTS)μ μ¬μ©ν©λλ€.
μ νν μ€ν νκ²½ μ μ§λ₯Ό μν΄ μλ κ°μ΄λλ₯Ό μ°Έκ³ νμ¬ λ²μ μ ν΅μΌν΄ μ£ΌμΈμ.
# .nvmrc λ΄ λͺ
μλ λ²μ μΌλ‘ Node.js μ€μΉ
nvm install
# μ€μΉλ λ²μ μ¬μ©
nvm useμ΄ νλ‘μ νΈλ pnpmμ μ¬μ©νλ©°, λ€λ₯Έ Node.js λ²μ μμ μμ‘΄μ± μ€μΉλ₯Ό λ°©μ§νκΈ° μν΄ λ€μ μ€μ μ΄ ν¬ν¨λμ΄ μμ΅λλ€:
# pnpm-workspace.yaml
nodeVersion: 22.16.0
# Node.js 22.16.0μ΄ μλ νκ²½μμλ pnpm installμ΄ μλ¬λ₯Ό λ°μμν΅λλ€
engineStrict: trueλ°λΌμ, μμ‘΄μ± μΆκ° λλ μ€μΉ μ , λ°λμ Node.js λ²μ μ νμΈνμΈμ:
node -v # v22.16.0 μ΄μ΄μΌ ν©λλ€# 1. νλ‘μ νΈ λ΄ Node.js λ²μ μ€μΉ
nvm install
nvm use
# 2. pnpm μ€μΉ (* μ€μΉκ° μλμ΄ μμ κ²½μ°)
corepack enable pnpm # λ‘컬 κΈλ‘λ² νκ²½μ pnpm μ€μΉ
corepack install # νλ‘μ νΈ λ΄ λͺ
μλ λ²μ μ package manager μ€μΉ
# 3. ν¨ν€μ§ μ€μΉ
pnpm installThis Turborepo includes the following packages/apps:
docs: a Next.js app with Tailwind CSSweb: another Next.js app with Tailwind CSSui: a stub React component library with Tailwind CSS shared by bothwebanddocsapplications@repo/eslint-config:eslintconfigurations (includeseslint-config-nextandeslint-config-prettier)@repo/typescript-config:tsconfig.jsons used throughout the monorepo
Each package/app is 100% TypeScript.
This example is set up to produce compiled styles for ui components into the dist directory. The component .tsx files are consumed by the Next.js apps directly using transpilePackages in next.config.ts. This was chosen for several reasons:
- Make sharing one
tailwind.config.tsto apps and packages as easy as possible. - Make package compilation simple by only depending on the Next.js Compiler and
tailwindcss. - Ensure Tailwind classes do not overwrite each other. The
uipackage uses aui-prefix for it's classes. - Maintain clear package export boundaries.
Another option is to consume packages/ui directly from source without building. If using this option, you will need to update the tailwind.config.ts in your apps to be aware of your package locations, so it can find all usages of the tailwindcss class names for CSS compilation.
For example, in tailwind.config.ts:
content: [
// app content
`src/**/*.{js,ts,jsx,tsx}`,
// include packages if not transpiling
"../../packages/ui/*.{js,ts,jsx,tsx}",
],If you choose this strategy, you can remove the tailwindcss and autoprefixer dependencies from the ui package.
This Turborepo has some additional tools already setup for you:
- Tailwind CSS for styles
- TypeScript for static type checking
- ESLint for code linting
- Prettier for code formatting