fix(desktop): skip obfuscation for electron main to preserve page.evaluate
Desktop Client Build / Resolve Build Metadata (push) Successful in 19s
Desktop Client Build / Build Desktop Client (push) Successful in 21m39s
Desktop Client Build / Publish Client Artifacts to NAS (push) Successful in 30s

Playwright serializes page.evaluate callbacks via Function.prototype.toString and runs them in the target page context. Obfuscating the main bundle injected string-array helper references that the browser page could not resolve, surfacing as `ReferenceError: wO is not defined` for bilibili and dongchedi publishes. Mirrors the existing Vite `minify: false` guard for main/preload.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Xu Liang
2026-05-09 17:46:37 +08:00
parent 1082e9010e
commit 708a45ba16
3 changed files with 24 additions and 6 deletions
+6 -6
View File
@@ -42,12 +42,12 @@ const baseOptions = {
}
const targets = [
{
label: 'main',
dir: path.join(outDir, 'main'),
match: (name) => name.endsWith('.cjs'),
options: { ...baseOptions, target: 'node' },
},
// Keep the Electron main process unobfuscated. It owns the Playwright
// adapters, and Playwright serializes `page.evaluate` callbacks with
// Function.prototype.toString(). Obfuscator string-array helpers live in the
// main bundle, not in the target web page, so packaged media publishers such
// as bilibili and dongchedi can fail with "ReferenceError: <helper> is not
// defined" inside the browser context.
{
label: 'renderer',
dir: path.join(outDir, 'renderer', 'assets'),