Skip to content

Commit 402b22f

Browse files
committed
feat: add noElectronStart CLI option to the dev command
1 parent 02e0dff commit 402b22f

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/cli.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ interface DevCLIOptions {
3232
inspect?: boolean | string
3333
inspectBrk?: boolean | string
3434
remoteDebuggingPort?: string
35+
noElectronStart?: boolean
3536
noSandbox?: boolean
3637
rendererOnly?: boolean
3738
}
@@ -78,6 +79,7 @@ cli
7879
.option('--inspect [port]', `[boolean | number] enable V8 inspector on the specified port`)
7980
.option('--inspectBrk [port]', `[boolean | number] enable V8 inspector on the specified port`)
8081
.option('--remoteDebuggingPort <port>', `[string] port for remote debugging`)
82+
.option('--noElectronStart', `[boolean] run dev servers without starting the Electron app`)
8183
.option('--noSandbox', `[boolean] forces renderer process to run un-sandboxed`)
8284
.option('--rendererOnly', `[boolean] only dev server for the renderer`)
8385
.action(async (root: string, options: DevCLIOptions & GlobalCLIOptions) => {
@@ -109,7 +111,7 @@ cli
109111
const inlineConfig = createInlineConfig(root, options)
110112

111113
try {
112-
await createServer(inlineConfig, { rendererOnly: options.rendererOnly })
114+
await createServer(inlineConfig, { rendererOnly: options.rendererOnly, noElectronStart: options.noElectronStart })
113115
} catch (e) {
114116
const error = e as Error
115117
createLogger(options.logLevel).error(

src/server.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { startElectron } from './electron'
1414

1515
export async function createServer(
1616
inlineConfig: InlineConfig = {},
17-
options: { rendererOnly?: boolean }
17+
options: { rendererOnly?: boolean; noElectronStart?: boolean }
1818
): Promise<void> {
1919
process.env.NODE_ENV_ELECTRON_VITE = 'development'
2020
const config = await resolveConfig(inlineConfig, 'serve', 'development')
@@ -104,9 +104,11 @@ export async function createServer(
104104
server.printUrls()
105105
}
106106

107-
ps = startElectron(inlineConfig.root)
107+
if(!options.noElectronStart) {
108+
ps = startElectron(inlineConfig.root)
108109

109-
logger.info(colors.green(`\nstart electron app...\n`))
110+
logger.info(colors.green(`\nstart electron app...\n`))
111+
}
110112
}
111113
}
112114

0 commit comments

Comments
 (0)