8396bdeb48
Playwright serializes the function passed to page.evaluate via .toString() and runs it in the browser context. With main-process minify on, esbuild renames inlined helpers (e.g. __name) and closure references to two-letter identifiers like FK/p/ed; their definitions stay at module scope on the Node side, so the browser eval throws ReferenceError. Mac dev builds were unaffected because dev mode doesn't minify; only packaged Windows builds hit this. Main process bundle size is irrelevant (loaded once on startup) so turning minify off is the cheapest correct fix. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
102 lines
2.9 KiB
TypeScript
102 lines
2.9 KiB
TypeScript
import { resolve } from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
import vue from '@vitejs/plugin-vue'
|
|
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
|
|
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'
|
|
import Components from 'unplugin-vue-components/vite'
|
|
|
|
const rootDir = fileURLToPath(new URL('.', import.meta.url))
|
|
|
|
const workspacePackages = [
|
|
'@geo/shared-types',
|
|
'@geo/http-client',
|
|
'@geo/publisher-platforms',
|
|
'@geo/ui-shared',
|
|
]
|
|
|
|
const workspaceAliases = {
|
|
'@geo/shared-types': resolve(rootDir, '../../packages/shared-types/src/index.ts'),
|
|
'@geo/http-client': resolve(rootDir, '../../packages/http-client/src/index.ts'),
|
|
'@geo/publisher-platforms': resolve(rootDir, '../../packages/publisher-platforms/src/index.ts'),
|
|
'@geo/ui-shared': resolve(rootDir, '../../packages/ui-shared/src/index.ts'),
|
|
'@geo/ui-shared/tokens': resolve(rootDir, '../../packages/ui-shared/src/tokens/index.ts'),
|
|
'@geo/ui-shared/tokens.css': resolve(rootDir, '../../packages/ui-shared/src/tokens/index.css'),
|
|
}
|
|
|
|
export default defineConfig({
|
|
main: {
|
|
plugins: [externalizeDepsPlugin({ exclude: workspacePackages })],
|
|
build: {
|
|
sourcemap: 'hidden',
|
|
// Disable minification for the main process: the bundle is only loaded
|
|
// once on app startup so size is irrelevant, and minified short names
|
|
// break Playwright `page.evaluate` because the function is serialized
|
|
// via `.toString()` and helper identifiers (e.g. `__name` renamed to
|
|
// `FK`) become undefined in the browser context.
|
|
minify: false,
|
|
rollupOptions: {
|
|
input: {
|
|
bootstrap: resolve(rootDir, 'src/main/bootstrap.ts'),
|
|
},
|
|
output: {
|
|
format: 'cjs',
|
|
entryFileNames: '[name].cjs',
|
|
chunkFileNames: '[name]-[hash].cjs',
|
|
},
|
|
},
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@main': resolve(rootDir, 'src/main'),
|
|
...workspaceAliases,
|
|
},
|
|
},
|
|
},
|
|
preload: {
|
|
plugins: [externalizeDepsPlugin({ exclude: workspacePackages })],
|
|
build: {
|
|
sourcemap: 'hidden',
|
|
minify: false,
|
|
rollupOptions: {
|
|
input: {
|
|
bridge: resolve(rootDir, 'src/preload/bridge.ts'),
|
|
},
|
|
output: {
|
|
format: 'cjs',
|
|
entryFileNames: '[name].cjs',
|
|
chunkFileNames: '[name]-[hash].cjs',
|
|
},
|
|
},
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@preload': resolve(rootDir, 'src/preload'),
|
|
...workspaceAliases,
|
|
},
|
|
},
|
|
},
|
|
renderer: {
|
|
plugins: [
|
|
vue(),
|
|
Components({
|
|
dts: false,
|
|
resolvers: [
|
|
AntDesignVueResolver({
|
|
importStyle: false,
|
|
}),
|
|
],
|
|
}),
|
|
],
|
|
build: {
|
|
sourcemap: 'hidden',
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@renderer': resolve(rootDir, 'src/renderer'),
|
|
...workspaceAliases,
|
|
},
|
|
},
|
|
},
|
|
})
|