Skip to content

Working great with Electron #139

@dapabe

Description

@dapabe

Topic and scope of discussion

Optional changes to be considered but not implemented, probably wiki about setting up this monorepo with electron-vite

Motivation

To make shared tooling across different JavaScript focused apps more bearable

Additional context

After thinkering a little (2 days) trying to find a proper monorepo or template, I have successfully set up these 2 enviroments without problem, I hope someone could benefit from this.

Versions:

Steps:
In the root dir cd apps -> pnpm create @quick-start/electron here probably you will run into problems, after it finished downloading do pnpm approve-builds it will prompt you with electron & esbuild select them so they can execute postinstall scripts, they will be added to below onlyBuiltDependencies in pnpm-workspace.yaml file.

Add the following lines to apps/{appName}/.npmrc:

node-linker=hoisted
shamefully-hoist=true
auto-install-peers=true

electron_mirror=https://npmmirror.com/mirrors/electron/
electron_builder_binaries_mirror=https://npmmirror.com/mirrors/electron-builder-binaries/

Optionally install xvfb-maybe to make use of the GUI in Linux if you need to, change the dev script to dev: xvfb-maybe electron-vite dev.

Important You should downgrade electron-builder to 24.13.3, you will encounter a lot of problems and errors with administration privilegies since their packages tries to use 7zip and and such other things and other more that I do not remember, I want to sleep its 3 a.m here.

Since electron needs some env variables (to which I do not know half of them), modify the root turbo.json into this:

Image

And why not; add this also to root package.json: "dev:desktop": "turbo dev --filter=\"{./apps/desktop}...\"", and this to .gitignore:

# Electron
apps/*/dist
apps/*/out
apps/*/electron-cache

Now you should be ready to pnpm install and pnpm dev
If you encounter a problem please tell me I will make the necesary changes.

Now I can go to sleep

Final output:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions