Quick Build
To build all apps and packages for production: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:Package Builds
Internal packages are built first (in order):
@repo/config-typescript@repo/eslint-config@repo/tailwind-config@repo/codegen@repo/dally@repo/ui
Application Builds
Applications are built after their dependencies:
console- Next.js production buildstorybook- Static Storybook site
Build Commands
Using Task Runner
Using Bun Directly
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
Authentication
Optional Features
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:^ prefix means “dependencies’ build tasks must complete first”.
Caching
Turborepo caches build outputs. Subsequent builds are instant if nothing changed:Parallel Execution
Independent packages build in parallel for faster builds.Build Variants
Production Build
Optimized for deployment:- Minified JavaScript
- Optimized images
- Tree-shaken dependencies
- Source maps (for debugging)
Development Build
Includes debugging information:Cleaning Build Artifacts
Clean Everything
Remove all build artifacts and dependencies:- All
node_modules/directories apps/console/.next/apps/storybook/.next/- App-specific
node_modules/
Turbo Clean
Clean only Turborepo cache:Complete Reinstall
Clean and reinstall everything:- Runs
task clean - Installs latest Turborepo
- Runs
turbo-clean - Reinstalls all dependencies
Type Checking
Run TypeScript type checking across all packages:Linting
Run ESLint across all packages:@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:Pre-commit Checks
Run all pre-commit checks (lint, format, type-check):- Installs pre-commit hooks
- Updates hooks to latest versions
- Runs all checks on all files
Build Troubleshooting
Out of Memory Errors
Increase Node.js memory limit:Stale Cache Issues
Clear Turborepo cache:Dependency Conflicts
Reinstall dependencies:Build Failures After Git Pull
Dependencies may have changed:CI/CD Builds
For continuous integration environments:Use
--frozen-lockfile in CI to ensure exact dependency versions and fail if bun.lockb is out of date.