Configuration Options

You can configure the behavior of turbo by adding a turbo object in the package.json in your monorepo's root (i.e. the same one you specify your workspaces key is set for Yarn and NPM users).

baseBranch

type: string

Defaults to origin/master. The base branch or your git repository. Git is used by turbo in its hashing algorithm and --since CLI flag.

globalDependencies

type: string[]

A list of globs and environment variables for implicit global hash dependencies. Environment variables should be prefixed with $ (e.g. $GITHUB_TOKEN). Any other entry without this prefix, will be considered filesystem glob. The contents of these files will be included in the global hashing algorithm and affect the hashes of all tasks. This is useful for busting the cache based on .env files (not in Git), environment variables, or any root level file that impacts package tasks (but are not represented in the traditional dependency graph (e.g. a root tsconfig.json, jest.config.js, .eslintrc, etc.)).

Example

{
"turbo": {
"pipeline": {
// ... omitted for brevity
},
"globalDependencies": [
".env", // contents will impact hashes of all tasks
"tsconfig.json", // contents will impact hashes of all tasks
"$GITHUB_TOKEN"// value will impact the hashes of all tasks
]
}
}

npmClient

type: "yarn" | "npm" | "pnpm"

Defaults to yarn. The NPM client in-use in your project.

pipeline

An object representing the task dependency graph of your project. turbo interprets these conventions to properly schedule, execute, and cache the outputs of tasks in your project.

Each key in the pipeline object is the name of a task that can be executed by turbo run. If turbo finds a workspace package with a package.json scripts object with a matching key, it will apply the pipeline task configuration to that NPM script during execution. This allows you to use pipeline to set conventions across your entire Turborepo.

{
"turbo": {
"pipeline": {
"build": {
"dependsOn": ["^build"]
},
"test": {
"outputs": ["coverage/**"],
"dependsOn": ["build"]
},
"dev": {
"cache": false
}
}
}
}

dependsOn

type: string[]

The list of tasks and environment variables that this task depends on.

Prefixing an item in dependsOn with a ^ tells turbo that this pipeline task depends on the package's topological dependencies completing the task with the ^ prefix first (e.g. "a package's build tasks should only run once all of its dependencies and devDependencies have completed their own build commands").

Items in dependsOn without ^ prefix, express the relationships between tasks at the package level (e.g. "a package's test and lint commands depend on build being completed first").

Prefixing an item in dependsOn with a $ tells turbo that this pipeline task depends the value of that environment variable.

Example: Basics

{
"turbo": {
"pipeline": {
"build": {
// "A package's `build` command depends on its dependencies'
// or devDependencies' `build` command being completed first"
"dependsOn": ["^build"]
},
"test": {
// "A package's `test` command depends on its own `lint` and
// `build` commands first being completed"
"dependsOn": ["lint", "build"]
},
"deploy": {
// "A package's `deploy` command, depends on its own `build`
// and `test` commands first being completed"
"dependsOn": ["build", "test"]
},
// A package's `lint` command has no dependencies
"lint": {}
}
}
}

Example: Environment Variables and Tasks

{
"turbo": {
"pipeline": {
"build": {
"dependsOn": {
"^build",
"$SOMETHING_ELSE" // value will impact the hashes of all build tasks
},
"outputs": ["dist/**", ".next/**"]
},
"web#build": {
"dependsOn": [
"^build",
"$STRIPE_SECRET_KEY", // value will impact hash of only web's build task
"$NEXT_PUBLIC_STRIPE_PUBLIC_KEY"
],
"outputs": [".next/**"]
}
},
"globalDependencies": [
"$GITHUB_TOKEN"// value will impact the hashes of all tasks
]
}
}

outputs

type: string[]

Defaults to ["dist/**", "build/**"]. The set of glob patterns of a task's cacheable filesystem outputs.

Note: turbo automatically logs stderr/stdout to .turbo/run-<task>.log. This file is always treated as a cacheable artifact and never needs to be specified.

Passing an empty array can be used to tell turbo that a task is a side-effect and thus doesn't emit any filesystem artifacts (e.g. like a linter), but you still want to cache its logs (and treat them like an artifact).

Example

{
"pipeline": {
"build": {
// "Cache all files emitted to package's dist/** or .next
// directories by a `build` task"
"outputs": ["dist/**", ".next/**"],
"dependsOn": ["^build"]
},
"test": {
// "Don't cache any artifacts of `test` tasks (aside from
// logs)"
"outputs": [],
"dependsOn": ["build"]
},
"test:ci": {
// "Cache the coverage report of a `test:ci` command"
"outputs": ["coverage/**"],
"dependsOn": ["build"]
},
"dev": {
// Never cache anything (including logs) emitted by a
// `dev` task
"cache": false
}
}
}

cache

type: boolean

Defaults to true. Whether or not to cache the task outputs. Setting cache to false is useful for daemon or long-running "watch" or development mode tasks that you don't want to cache.

Example

{
"pipeline": {
"build": {
"dependsOn": ["^build"]
},
"test": {
"outputs": [],
"dependsOn": ["build"]
},
"dev": {
"cache": false
}
}
}