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

How to disable automatic opening of the electron window on vite #257

Open
rafaellehmkuhl opened this issue Oct 14, 2024 · 1 comment
Open

Comments

@rafaellehmkuhl
Copy link

The project I work on supports usage as both an electron app as well as a web page, and most of the time, for practical purposes, we develop by previewing only the application as a web page, not dealing with the electron window.

We have a script command called dev which calls vite --host. We were previously using version 0.9.3 of this plugin, in which the electron window was not being opened by default, but since we updated to the latest version (0.28.8), the electron window is being opened by default with this same command.

Is there a way to disable it, so I can have a dedicated command (e.g.: dev:electron) that explicitly calls for the electron window to be opened (e.g.: vite --host && electron .)?

@rafaellehmkuhl
Copy link
Author

My hacky workaround here for now:

On package.json:

"dev:electron": "ELECTRON=true vite --host"

On vite.config.ts:

// Check if we're running in Electron mode
const isElectron = process.env.ELECTRON === 'true'

export default defineConfig({
  plugins: [
    isElectron &&
      electron(...),
    ...
  ].filter(Boolean),
  ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant