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

Multiple vite apps served by the renderer #462

Open
4 tasks done
shennan opened this issue Mar 29, 2024 · 0 comments
Open
4 tasks done

Multiple vite apps served by the renderer #462

shennan opened this issue Mar 29, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@shennan
Copy link

shennan commented Mar 29, 2024

Clear and concise description of the problem

Great project; thanks for the work here.

I have a monorepo with a few Vite apps. For testing purposes it would be great to use Electron Vite to serve all of them through one Electron instance and use a hidden button or shortcut to flip between them.

Example monorepo:


monorepo/
├─ emulator (electron-vite)/
│  ├─ package.json
│  ├─ electron.vite.config.ts
├─ vite-app1/
│  ├─ package.json
│  ├─ index.html
├─ vite-app2/
│  ├─ package.json
│  ├─ index.html

In the above scenario, the emulator package would fire up App1 and App2 in different BrowserWindow's which can be switched between.

I see you have documentation for a "Multiple Windows App" but this seems different. If I, say, adjust the config to this:

/*...*/
renderer: {
    root: '../vite-app1/',
    build: {
      rollupOptions: {
        input: {
          'user-app': resolve('../vite-app1/index.html'),
          'control-panel': resolve('../vite-app2/index.html')
        }
      }
    },
/*...*/

I'm still able to see App1, but I'm unable to access/load App2. This makes sense because presumably they would clash anyway due to listening on the same port.

Is this beyond the scope of Electron Vite. And, if so, how would you go about achieving this with what is currently available in the codebase?

Suggested solution

Have the input property run vite on different ports and load the process.env['ELECTRON_RENDERER_URL'] with namespaced URLs.

Alternative

No response

Additional context

This is mostly a desire for less boilerplate code. The apps have distinct lives of their own but they are also useful together. Electron Vite, in this case, is a distribution "flavour" of the monorepo.

Validations

@shennan shennan added the enhancement New feature or request label Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant