Skip to main content
This guide covers building Openlane UI for production and understanding the build process.

Quick Build

To build all apps and packages for production:
task build
This runs bun run build which uses Turborepo to build all packages and applications in the correct order.

Build Process

The build system uses Turborepo to orchestrate builds across the monorepo:
1

Dependency Resolution

Turborepo analyzes the dependency graph and determines the build order.
2

Package Builds

Internal packages are built first (in order):
  • @repo/config-typescript
  • @repo/eslint-config
  • @repo/tailwind-config
  • @repo/codegen
  • @repo/dally
  • @repo/ui
3

Application Builds

Applications are built after their dependencies:
  • console - Next.js production build
  • storybook - Static Storybook site
4

Output Generation

Build artifacts are generated:
  • .next/ - Next.js production output
  • dist/ - Package builds
  • storybook-static/ - Static Storybook files

Build Commands

Using Task Runner

task build

Using Bun Directly

bun run build

Build Outputs

After a successful build, you’ll find:

Applications

  • Console: apps/console/.next/ - Next.js optimized production build
  • Storybook: apps/storybook/storybook-static/ - Static HTML/CSS/JS files

Packages

  • All packages: packages/*/dist/ - Compiled JavaScript and type definitions
Build artifacts are excluded from the Turborepo cache using the outputs configuration in turbo.json. The .next/cache/** directory is specifically excluded to prevent cache bloat.

Environment Variables for Builds

The build process uses environment variables defined in your .env file. Key variables include:

Required for Builds

# API Configuration
API_REST_URL=http://localhost:17608
NEXT_PUBLIC_OPENLANE_URL=http://localhost:17608
NEXT_PUBLIC_API_GQL_URL=http://localhost:17608/query

Authentication

AUTH_GITHUB_ID=your_github_client_id
AUTH_GITHUB_SECRET=your_github_secret
AUTH_GOOGLE_ID=your_google_client_id
AUTH_GOOGLE_SECRET=your_google_secret
SESSION_COOKIE_NAME=temporary-cookie
NEXT_PUBLIC_ALLOWED_LOGIN_DOMAINS=

Optional Features

# Billing
STRIPE_SECRET_KEY=your_stripe_key

# Analytics
PIRSCH_SECRET=your_pirsch_secret
PIRSCH_CLIENT_ID=your_pirsch_client_id

# AI Features
NEXT_PUBLIC_AI_SUGGESTIONS_ENABLED=false
GOOGLE_AI_PROJECT_ID=your_project_id
GOOGLE_AI_REGION=us-central1
See turbo.json for the complete list of environment variables used during builds. Variables prefixed with NEXT_PUBLIC_ are embedded in the client bundle.

Build Optimization

Turborepo provides several optimizations:

Dependency-Based Builds

Packages are built based on their dependencies:
"build": {
  "dependsOn": ["^build"]
}
The ^ prefix means “dependencies’ build tasks must complete first”.

Caching

Turborepo caches build outputs. Subsequent builds are instant if nothing changed:
# First build
task build  # Takes 2-3 minutes

# Second build (no changes)
task build  # Completes in seconds (cache hit)

Parallel Execution

Independent packages build in parallel for faster builds.

Build Variants

Production Build

Optimized for deployment:
task build
Features:
  • Minified JavaScript
  • Optimized images
  • Tree-shaken dependencies
  • Source maps (for debugging)

Development Build

Includes debugging information:
task build:dev
Runs in the console directory with debug mode enabled.

Cleaning Build Artifacts

Clean Everything

Remove all build artifacts and dependencies:
task clean
This removes:
  • All node_modules/ directories
  • apps/console/.next/
  • apps/storybook/.next/
  • App-specific node_modules/

Turbo Clean

Clean only Turborepo cache:
bun run turbo-clean

Complete Reinstall

Clean and reinstall everything:
task reinstall
This:
  1. Runs task clean
  2. Installs latest Turborepo
  3. Runs turbo-clean
  4. Reinstalls all dependencies

Type Checking

Run TypeScript type checking across all packages:
bun run type-check
Or with Turborepo:
turbo type-check
This validates types without emitting build output.

Linting

Run ESLint across all packages:
bun run lint
The lint configuration is shared via @repo/eslint-config and enforces:
  • TypeScript best practices
  • React and React Hooks rules
  • Import ordering
  • Accessibility (jsx-a11y)
  • TSDoc comments

Formatting

Format code before building:
bun run format
This runs Prettier on all TypeScript, TSX, and Markdown files with Tailwind CSS plugin support.

Pre-commit Checks

Run all pre-commit checks (lint, format, type-check):
task precommit-full
This:
  1. Installs pre-commit hooks
  2. Updates hooks to latest versions
  3. Runs all checks on all files

Build Troubleshooting

Out of Memory Errors

Increase Node.js memory limit:
NODE_OPTIONS="--max-old-space-size=4096" task build

Stale Cache Issues

Clear Turborepo cache:
task turbo-clean
task build

Dependency Conflicts

Reinstall dependencies:
task reinstall

Build Failures After Git Pull

Dependencies may have changed:
task install
task build

CI/CD Builds

For continuous integration environments:
# Install dependencies
bun install --frozen-lockfile

# Run type checking
bun run type-check

# Run linting
bun run lint

# Build all packages
bun run build
Use --frozen-lockfile in CI to ensure exact dependency versions and fail if bun.lockb is out of date.

Next Steps

Build docs developers (and LLMs) love