Skip to content

Commit 9b04362

Browse files
authored
feat: support for passing arguments to electron in dev and preview commands (#339)
1 parent a8f5182 commit 9b04362

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/cli.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ cli
9797
process.env.NO_SANDBOX = '1'
9898
}
9999

100+
if (options['--']) {
101+
process.env.ELECTRON_CLI_ARGS = JSON.stringify(options['--']);
102+
}
103+
100104
if (options.entry) {
101105
process.env.ELECTRON_ENTRY = options.entry
102106
}
@@ -151,6 +155,10 @@ cli
151155
process.env.ELECTRON_ENTRY = options.entry
152156
}
153157

158+
if (options['--']) {
159+
process.env.ELECTRON_CLI_ARGS = JSON.stringify(options['--']);
160+
}
161+
154162
try {
155163
await preview(inlineConfig, { skipBuild: options.skipBuild })
156164
} catch (e) {

src/electron.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export function startElectron(root: string | undefined): ChildProcess {
125125

126126
const isDev = process.env.NODE_ENV_ELECTRON_VITE === 'development'
127127

128-
const args: string[] = []
128+
const args: string[] = process.env.ELECTRON_CLI_ARGS ? JSON.parse(process.env.ELECTRON_CLI_ARGS) : []
129129

130130
if (!!process.env.REMOTE_DEBUGGING_PORT && isDev) {
131131
args.push(`--remote-debugging-port=${process.env.REMOTE_DEBUGGING_PORT}`)

0 commit comments

Comments
 (0)