feat: support for passing arguments to electron in dev and preview commands (#339)

This commit is contained in:
Mikael Finstad 2023-12-16 17:11:27 +08:00 committed by GitHub
parent a8f5182d25
commit 9b04362e12
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View file

@ -97,6 +97,10 @@ cli
process.env.NO_SANDBOX = '1'
}
if (options['--']) {
process.env.ELECTRON_CLI_ARGS = JSON.stringify(options['--']);
}
if (options.entry) {
process.env.ELECTRON_ENTRY = options.entry
}
@ -151,6 +155,10 @@ cli
process.env.ELECTRON_ENTRY = options.entry
}
if (options['--']) {
process.env.ELECTRON_CLI_ARGS = JSON.stringify(options['--']);
}
try {
await preview(inlineConfig, { skipBuild: options.skipBuild })
} catch (e) {

View file

@ -125,7 +125,7 @@ export function startElectron(root: string | undefined): ChildProcess {
const isDev = process.env.NODE_ENV_ELECTRON_VITE === 'development'
const args: string[] = []
const args: string[] = process.env.ELECTRON_CLI_ARGS ? JSON.parse(process.env.ELECTRON_CLI_ARGS) : []
if (!!process.env.REMOTE_DEBUGGING_PORT && isDev) {
args.push(`--remote-debugging-port=${process.env.REMOTE_DEBUGGING_PORT}`)