yarn workspace & turborepo
Yarn workspaces & Turborepo 를 이용한 프론트엔드 Monorepo 구축
# 1. 프로젝트 디렉토리 생성 및 이동
mkdir design-system-monorepo-sample && cd design-system-monorepo-sample
# 2. Yarn 초기화
yarn init -y
# 3. package.json 파일 수정
cat <<EOT > package.json
{
"name": "design-system-monorepo-sample",
"private": true,
"workspaces": [
"packages/*"
],
"scripts": {
"build": "turbo run build",
"test": "turbo run test",
"lint": "turbo run lint"
},
"devDependencies": {
"turbo": "latest"
}
}
EOT
# 4. Turborepo 설치
yarn add turbo -D -W
# 5. turbo.json 설정 파일 생성
cat <<EOT > turbo.json
{
"$schema": "https://turbo.build/schema.json",
"pipeline": {
"build": {
"dependsOn": ["^build"],
"outputs": ["dist/**"]
},
"test": {
"dependsOn": ["build"],
"outputs": []
},
"lint": {
"outputs": []
}
}
}
EOT
# 6. packages 디렉토리 생성 및 하위 프로젝트 생성
mkdir -p packages/design-system-react packages/design-system-lit packages/common
# 7. 각 패키지의 package.json 파일 생성
# design-system-react
cat <<EOT > packages/design-system-react/package.json
{
"name": "@my-org/design-system-react",
"version": "1.0.0",
"main": "dist/index.js",
"scripts": {
"build": "echo 'Building React components'",
"test": "echo 'Testing React components'",
"lint": "echo 'Linting React components'"
},
"dependencies": {
"@my-org/common": "1.0.0"
}
}
EOT
# design-system-lit
cat <<EOT > packages/design-system-lit/package.json
{
"name": "@my-org/design-system-lit",
"version": "1.0.0",
"main": "dist/index.js",
"scripts": {
"build": "echo 'Building Lit components'",
"test": "echo 'Testing Lit components'",
"lint": "echo 'Linting Lit components'"
},
"dependencies": {
"@my-org/common": "1.0.0"
}
}
EOT
# common
cat <<EOT > packages/common/package.json
{
"name": "@my-org/common",
"version": "1.0.0",
"main": "dist/index.js",
"scripts": {
"build": "echo 'Building common utilities'",
"test": "echo 'Testing common utilities'",
"lint": "echo 'Linting common utilities'"
}
}
EOT
# 8. .gitignore 파일 생성
echo "node_modules
dist
.turbo" > .gitignore
# 9. 의존성 설치
yarn install