Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add noElectronStart CLI option to the dev command #578

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ interface DevCLIOptions {
inspect?: boolean | string
inspectBrk?: boolean | string
remoteDebuggingPort?: string
noElectronStart?: boolean
noSandbox?: boolean
rendererOnly?: boolean
}
Expand Down Expand Up @@ -78,6 +79,7 @@ cli
.option('--inspect [port]', `[boolean | number] enable V8 inspector on the specified port`)
.option('--inspectBrk [port]', `[boolean | number] enable V8 inspector on the specified port`)
.option('--remoteDebuggingPort <port>', `[string] port for remote debugging`)
.option('--noElectronStart', `[boolean] run dev servers without starting the Electron app`)
.option('--noSandbox', `[boolean] forces renderer process to run un-sandboxed`)
.option('--rendererOnly', `[boolean] only dev server for the renderer`)
.action(async (root: string, options: DevCLIOptions & GlobalCLIOptions) => {
Expand Down Expand Up @@ -109,7 +111,7 @@ cli
const inlineConfig = createInlineConfig(root, options)

try {
await createServer(inlineConfig, { rendererOnly: options.rendererOnly })
await createServer(inlineConfig, { rendererOnly: options.rendererOnly, noElectronStart: options.noElectronStart })
} catch (e) {
const error = e as Error
createLogger(options.logLevel).error(
Expand Down
8 changes: 5 additions & 3 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { startElectron } from './electron'

export async function createServer(
inlineConfig: InlineConfig = {},
options: { rendererOnly?: boolean }
options: { rendererOnly?: boolean; noElectronStart?: boolean }
): Promise<void> {
process.env.NODE_ENV_ELECTRON_VITE = 'development'
const config = await resolveConfig(inlineConfig, 'serve', 'development')
Expand Down Expand Up @@ -104,9 +104,11 @@ export async function createServer(
server.printUrls()
}

ps = startElectron(inlineConfig.root)
if(!options.noElectronStart) {
ps = startElectron(inlineConfig.root)

logger.info(colors.green(`\nstart electron app...\n`))
logger.info(colors.green(`\nstart electron app...\n`))
}
}
}

Expand Down