# What Build Tools Are Used in the Cypress Monorepo?

> Discover the build tools powering the Cypress monorepo. Explore Yarn Lerna Vite Webpack Packherd and V8-snapshot for efficient development.

- Repository: [Cypress.io/cypress](https://github.com/cypress-io/cypress)
- Tags: internals
- Published: 2026-08-06

---

**The Cypress monorepo relies on Yarn 1 and Lerna for workspace management, Vite and Webpack for bundling, and specialized tooling including Packherd and V8-snapshot generation for the Electron runtime.**

The `cypress-io/cypress` repository is a complex, multi-package workspace containing dozens of interconnected modules that power the popular end-to-end testing framework. Understanding what build tools are used in the Cypress monorepo is essential for contributors modifying the driver, desktop GUI, or Electron application packaging pipeline.

## Package Management and Monorepo Orchestration

The foundation of the build system rests on **Yarn 1** (v1.22.22) acting as the primary package manager, paired with **Lerna** to orchestrate cross-package commands.

In the root [`package.json`](https://github.com/cypress-io/cypress/blob/main/package.json), Yarn scripts invoke Lerna to run standardized operations across all packages. This configuration handles dependency installation, linking local packages, and executing build commands in the correct topological order. The root scripts section defines commands like `build`, `lint`, and `test` that leverage Lerna's ability to run commands across the entire workspace.

Key configuration locations include:
- **Root [`package.json`](https://github.com/cypress-io/cypress/blob/main/package.json)** – Defines the Yarn scripts and Lerna-driven workflows that coordinate builds across the monorepo.
- **`packages/ts/`** – Houses the shared TypeScript configuration used by all packages to ensure consistent compilation settings.

## Build and Bundle Tools

The monorepo employs multiple bundlers tailored to specific package requirements rather than a single universal tool.

### Vite for the Electron UI

Modern packages within the monorepo, specifically `@packages/app` and `@packages/launchpad`, use **Vite** as their development server and production bundler. Vite provides on-the-fly ES-module transforms during development and optimized builds for the Electron renderer process.

The configuration resides in [`packages/app/vite.config.ts`](https://github.com/cypress-io/cypress/blob/main/packages/app/vite.config.ts), where the build pipeline defines entry points, plugin configurations, and optimizations specific to the Cypress desktop GUI. Running `yarn dev` starts the Vite development servers for these packages, enabling hot-module reloading during UI development.

### Webpack for the Driver and Legacy Bundles

Several internal packages, particularly the test driver (`@packages/driver`), continue to use **Webpack** for bundling. The configuration in [`packages/driver/webpack.config.js`](https://github.com/cypress-io/cypress/blob/main/packages/driver/webpack.config.js) handles the complex transformation of the legacy driver code, including component-testing adapters and browser-specific polyfills.

Webpack remains necessary for these components due to specific loader requirements and the need to maintain compatibility with older browser environments that the driver must support.

## Electron-Specific Build Tooling

Beyond standard JavaScript bundling, Cypress employs custom tooling to optimize the Electron application startup and distribution size.

### Packherd for Dependency Bundling

**Packherd** bundles the exact set of dependencies required by the Electron runtime into a minimal artifact, reducing runtime bloat and installation size. Located under `tooling/packherd/`, this tool executes after the JavaScript bundles are produced, creating a compact dependency package that the Electron binary consumes.

The Packherd step runs automatically via post-install hooks, though you can invoke it manually using `node tooling/packherd/scripts/pack.js` when debugging the Electron packaging process.

### V8 Snapshot Generation

To dramatically reduce Electron startup latency, the monorepo implements **V8 snapshot tooling** that generates snapshot files used during application initialization. This process involves two components:

- **`tooling/v8-snapshot/`** – Contains scripts and source code for generating the snapshot files, including [`build-dev.js`](https://github.com/cypress-io/cypress/blob/main/build-dev.js) and [`build-prod.js`](https://github.com/cypress-io/cypress/blob/main/build-prod.js) used by the root [`package.json`](https://github.com/cypress-io/cypress/blob/main/package.json) scripts.
- **`tooling/electron-mksnapshot/`** – Wraps the upstream `mksnapshot` binary specific to the Electron version Cypress ships with, integrating the snapshot generation into the build pipeline.

The root [`package.json`](https://github.com/cypress-io/cypress/blob/main/package.json) exposes these via `yarn build-v8-snapshot-dev` for development builds and `yarn build-v8-snapshot-prod` for production releases.

## Running the Build Pipeline

Execute the complete build workflow using the Yarn scripts defined in the root [`package.json`](https://github.com/cypress-io/cypress/blob/main/package.json):

Install all dependencies and trigger post-install hooks (including Packherd and V8 snapshot preparation):

```bash
yarn

```

Build all packages in development mode (unminified, fast iteration):

```bash
yarn build

```

Generate production-ready V8 snapshots for the released Electron binary:

```bash
yarn build-v8-snapshot-prod

```

Launch the development environment with hot-module reloading via Vite:

```bash
yarn dev

```

## Summary

- **Yarn 1** and **Lerna** manage the monorepo workspace and orchestrate cross-package builds from the root [`package.json`](https://github.com/cypress-io/cypress/blob/main/package.json).
- **Vite** powers the modern Electron UI packages (`@packages/app`, `@packages/launchpad`) with fast development and ES-module support.
- **Webpack** handles bundling for the legacy driver package (`@packages/driver`) and component-testing adapters.
- **Packherd** (`tooling/packherd/`) creates minimal dependency bundles for the Electron runtime.
- **V8 snapshot tooling** (`tooling/v8-snapshot/` and `tooling/electron-mksnapshot/`) generates startup snapshots to reduce application launch time.
- **TypeScript** configuration is centralized in `packages/ts/` and applied consistently across all workspace packages.

## Frequently Asked Questions

### Does Cypress use Vite or Webpack for the main application?

Cypress uses both. **Vite** handles the Electron GUI (the desktop application interface found in `@packages/app` and `@packages/launchpad`), while **Webpack** continues to bundle the test driver (`@packages/driver`) and certain legacy internal packages that require specific loader configurations for browser compatibility.

### What is Packherd used for in the Cypress build process?

**Packherd** analyzes the dependency tree of the Electron main process and bundles only the required modules into a compact artifact. According to the source code in `tooling/packherd/`, this reduces the distributed application size by eliminating unnecessary files from `node_modules` while ensuring all runtime dependencies are available to the Electron binary.

### How does the V8 snapshot tooling improve Cypress startup performance?

The **V8 snapshot tooling** pre-compiles JavaScript code into a binary snapshot format that V8 can load instantly without parsing. Located in `tooling/v8-snapshot/` and integrated via `tooling/electron-mksnapshot/`, this process generates `.bin` snapshot files during the build that the Electron binary loads at startup, significantly reducing the time from application launch to interactive state.

### Why does Cypress use Lerna with Yarn instead of Yarn workspaces alone?

While Yarn 1 handles dependency installation and workspace linking, **Lerna** provides additional orchestration capabilities for running commands across packages in dependency order and managing version bumping during releases. The root [`package.json`](https://github.com/cypress-io/cypress/blob/main/package.json) scripts leverage Lerna to execute builds, tests, and linting across the dozens of packages in `cypress-io/cypress` while respecting inter-package dependencies.