Introduction | Turborepo

Turborepo and Monorepos

turborepo/examples at main ยท vercel/turborepo

Initialization

  1. Run the command

    npx create-turbo@latest
    
  2. Start Server

    npm run dev
    

Adding React Project

  1. navigate to apps folder

  2. Create a React Project

    npm create vite@latest 
    
  3. Add ui as dependency to package.json in new react app

    "@repo/ui": "*"
    
  4. Add a turbo.json to the react folder to override the outputs object of this module

    {
      "extends": ["//"],
      "tasks": {
        "build": {
          "outputs": ["dist/**"]
        }
      }
    }
    

Adding Express Project

  1. Initialize package.json

    npm init -y
    
  2. Initialize typescript

    npx tsc --init
    
  3. Edit tsconfig.json

    {
      "extends": "@repo/typescript-config/base.json",
      "compilerOptions": {
        "lib": ["ES2015"],
        "rootDir": "./src",
        "outDir": "./dist",
        "module": "NodeNext",
      },
      "exclude": ["node_modules"],
      "include": ["src"]
    }
    
  4. Add turbo.json

    {
      "extends": ["//"],
      "tasks": {
        "build": {
          "env": ["PORT"],
          "outputs": ["dist/**"]
        }
      }
    }
    

Adding Common package