PostHog / PostHog/posthog

feat(devex): Align on Vite for production builds

Open
#50,871 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
39.9k
Forks
3.4k
Avg merge
6h 51m
Merged PRs (30d)
232

Description

Context

We switched the frontend dev server to Vite in July 2025 (PR #35247), but production builds still go through a custom esbuild pipeline (frontend/build.mjs + @posthog/esbuilder). That means two separate build systems with different configs, different behavior, and different bugs.

Goal

Use Vite as the single build tool for both development and production.

Scope / ideas

  • Audit what the esbuild pipeline does beyond bundling — multi-entry-point builds (index, exporter, render-query, toolbar), metadata generation, parallel build orchestration
  • Set up a Vite production build and validate output against current esbuild output (bundle size, chunking, etc.)
  • Replace esbuild prod config with Vite
  • Verify CI pipelines and deploy still work with the new build

Current state

  • Vite 7.x for dev (frontend/vite.config.ts), esbuild 0.25.x for prod (frontend/build.mjs, common/esbuilder/utils.mjs)
  • There was a previous attempt at Vite prod builds with an env flag POSTHOG_USE_VITE_PROD=1 (PRs #40432, #40431, Oct 2025) — both were closed without merging, marked WIP

Open questions

  • Why were the previous Vite prod PRs abandoned? Blockers worth understanding before another attempt.

References

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading frontend/vite.config.ts and frontend/build.mjs, then inspect common/esbuilder/utils.mjs to inventory the current production pipeline. Review closed PR #40432 to understand prior blockers. Done means Vite handles the listed production entry points, output is compared with esbuild, and CI and deployment are verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript, vite
Domain
build-system, developer-experience, frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.