How to ship Playwright's Chromium inside a packaged Electron app
Electron apps that use Playwright for scraping require a second, separate Chromium instance because Electron's built-in Chromium is tied to the UI renderer and incompatible with Playwright's automation expectations. In packaged builds, Playwright cannot find its browser cache, so developers must manually resolve the executable path per platform and pass it explicitly at launch. The Chromium build number is hardcoded in the directory path, meaning an unpinned Playwright version upgrade silently breaks packaged apps while development environments continue working from a refreshed cache. On macOS, the correct executable sits deep inside an app bundle rather than at the bundle root, and both arm64 and x64 variants must be present for universal builds with runtime architecture detection. Because Electron's asar packaging prevents the OS from executing binaries stored inside the archive, the browser binaries must be explicitly unpacked to an app.asar.unpacked directory via a dedicated prebuild copy script.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in