make find-chrome-bin as external dependencies to resolve production build runtime error

This commit is contained in:
geekgeekrun
2024-02-25 14:39:48 +08:00
parent 1557ed26b9
commit 17cdbd871c
6 changed files with 55 additions and 5 deletions
@@ -1,7 +1,23 @@
import { findChrome } from "find-chrome-bin";
import { is } from '@electron-toolkit/utils'
import electron from 'electron'
import * as os from 'node:os'
import path from 'node:path'
export default async function findAndLocateExistedChromiumExecutable() {
let findChrome: typeof import('find-chrome-bin').findChrome
if (is.dev) {
findChrome = (await import('find-chrome-bin')).findChrome
} else {
findChrome = (
await import(
path.resolve(
electron.app.getAppPath(),
'..',
'external-node-runtime-dependencies/index.mjs'
)
)
).findChromeBin.findChrome
}
// For windows, try to find Edge(chromium)
if (os.platform() === 'win32') {
// TODO: handle windows