1단계: 모노레포 초기 설정 (pnpm & Workspace)

pnpm 설치

# pnpm 10.x 버전 설치
npm install -g pnpm@latest-10

pnpm 초기화

  1. 프로젝트 루트에서 package.json 생성
pnpm init
{
  "name": "web30-boostcamp",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \\"Error: no test specified\\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "packageManager": "pnpm@10.20.0"
}
  1. pnpm-workspace.yaml 생성
packages:
  - "packages/*"
  - "apps/*"

Turborepo 설치 및 루트 package.json 설정

pnpm add turbo -D -w

package.json에 turbo 실행 스크립트와 패키지 매니저를 지정

{
  "name": "web30-boostcamp",
  "version": "1.0.0",
  "description": "code rena battle project",
  "scripts": {
    "test": "echo \\"Error: no test specified\\" && exit 1",
    "build": "turbo run build",
    "dev": "turbo run dev --parallel",
    "lint": "turbo run lint",
    "clean": "turbo run clean"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "packageManager": "pnpm@10.20.0",
  "devDependencies": {
    "turbo": "^2.6.3"
  }
}

turbo.json

{
    "$schema": "<https://turborepo.org/schema.json>",
    "pipeline": {
      "build": {
        "dependsOn": ["^build"],
        "outputs": ["dist/**", ".next/**"]
      },
      "dev": {
        "cache": false,
        "persistent": true
      },
      "lint": {},
      "clean": {
        "cache": false
      }
    }
  }