Repo
Docs
Building Your App

Building your App

Unless your monorepo is only used for publishing packages to npm, it will likely contain at least one application. Coordinating your app's builds with Turborepo can lead to some extraordinary gains in speed.

Setting up the build

Turborepo works by keeping your workspace tasks where they belong - in each workspace's package.json. Let's imagine you have a monorepo that looks like this:

├── apps
│   └── web
│       └── package.json
├── package.json
└── turbo.json

Your apps/web/package.json should have a build script inside:

apps/web/package.json
{
  "scripts": {
    "build": "next build"
  }
}

Inside turbo.json, you can add build to the pipeline.

turbo.json
{
  "pipeline": {
    "build": {
      "outputs": [".next/**", "!.next/cache/**"]
    }
  }
}

We configure the outputs so that we can enable caching - an extremely powerful feature of Turborepo that can skip tasks that have been done before.

This means that running turbo build from root will build all of the apps in the repository. Thanks to Turborepo's task cache, you can end up with extremely fast build times.