According to the documentation: https://electronjs.org/docs/tutorial/application-distribution
First you must download pre-compiled binaries: https://github.com/electron/electron/releases
Then copy your project folder into the folder ./resources
of the precompiled
The structure in Macosx should be:
electron/Electron.app/Contents/Resources/app/
├── package.json
├── main.js
└── index.html
And Windows or Linux like that:
electron/resources/app
├── package.json
├── main.js
└── index.html
The briefcase ./app
is your project in case, then you will notice in the above folder in Windows the electron.exe
on linux will be just electron
no extension, but it is an executable, both can be renamed to the name of your program or as you wish.
On your Mac your own folder Electron.app
is an application (this is how it works on Mac).
You can also compress into ASAR as stated in: https://electronjs.org/docs/tutorial/application-distribution#distributing-your-app-as-just-a-file
To package install asar globally:
npm install -g asar
And then point the folder of your project to the swap command <pasta do projeto>
by his briefcase:
asar pack <pasta do projeto> app.asar
In linux and windows should put inside the pre-compiled so:
electron/resources/
└── app.asar
And the process is the same, in linux run the file electron
in windows run the electron.exe
(again both can be renamed)
On Mac this must be the way:
electron/Electron.app/Contents/Resources/
└── app.asar
To facilitate the https://www.npmjs.com/package/electron-packager
Note: I didn’t test, maybe on the weekend I’ll test calmly and do a review
To install:
npm install electron-packager -g
Then run the command according to the desired environment:
electron-packager <sourcedir> <appname> --platform=<platform> --arch=<arch>
sourcedir is the project folder, appname is the name of the desired app, Platform the target platform, in case Platform and Arch can be omitted if you are going to use the parameter --all
that will generate for all available platforms
You can also install Electron-packager as devDependencies directly in your project and add it to package.json in build, something similar to this
"scripts": {
...
"build": "electron-packager ."
},
The answer is in edition/improvements
Controversies and personal opinion
A major problem that many devs face is reverse engineering, especially when apps have sensitive data, such as private keys for authentication, Electron is by far not a safe environment from this point of view, knowing well what it does, isolating a key per person avoiding creating a communication with your back-end in exposed form Electron will not be a problem, but if you do not have reasonable security knowledge anyone with some knowledge will be able to extract the asar
(a lot of bad luck/asar, sorry for the joke) and analyze the code to see how to exploit loopholes.
Almost all "Exes of life" can suffer from this, but the format asar
is immensely easier to suffer from this.
There are solutions that I consider palliative or call as small reinforcements as the package: https://www.npmjs.com/package/uglify-js (I didn’t get to test), maybe Electron already has something of its own, some time ago I didn’t work with it (I switched to another platform), but even this is not a solution is just a reinforcement. So you must always think of these details.
The text so far is not to suggest fancy, magical solutions or anything like that, because reverse engineering is not something that has a solution, what we can do is make it difficult or create an environment (like keys) for each person, thus making the only responsible be the user himself, but I will not go into detail because this may confuse many people and I will really need to review the text in the future.
In editing for the future, I will suggest tool(s) that make a complete pack into a single executable file that can help but is not foolproof against reverse engineering