- Electron Projects
- Denys Vuika
- 304字
- 2021-06-24 12:14:34
Packaging for Windows
Now that you know how to set up build scripts for macOS and Ubuntu Linux, configuring for Windows shouldn't be a problem for you.
As I mentioned earlier, it is possible and also recommended to keep the configuration files for all platforms in a single code repository, inside the package.json file. The build scripts for Windows are shown in the following code:
{
"scripts": {
"start": "electron .",
"build:windows": "electron-builder --win --dir",
"dist:windows": "electron-builder --win"
}
}
Both scripts should be familiar to you. The build:windows script creates an unpacked local build for development and testing purposes, while the dist:windows script prepares the application for distribution.
Let's try to build and run the development version of the application:
- Open the Terminal window in Visual Studio Code, or a Command Prompt tool, and run the following script:
npm run build:windows
Note that you can build Windows packages with macOS or Ubuntu Linux if you have the Wine tool installed, but I recommend having a virtual machine nearby for testing purposes. It should also be possible to build for Linux on a Windows machine, but you may want to have a real Linux machine for application testing purposes.
- Once the script exits, you should see the prebuilt application, that is, my-first-app.exe, in the dist/win-unpacked folder.
- Double-click on the my-first-app.exe file to run the application:

- We need to use the build:windows script to create a distribution package for testing purposes. Let's check that we can build packages for redistribution:
npm run dist:windows
- Check the dist folder once again. You should see the my-first-app Setup 1.0.0.exe installer file alongside the win-unpacked folder:

- Now, double-click the installer file. The setup wizard should set up the application and automatically launch it.
Congratulations—you've got your first cross-platform Electron application package up and running on Windows 10!
推薦閱讀
- PHP基礎案例教程
- Xamarin.Forms Projects
- Spring Boot企業(yè)級項目開發(fā)實戰(zhàn)
- Java實戰(zhàn)(第2版)
- Java網(wǎng)絡編程實戰(zhàn)
- 軟件項目管理實用教程
- 會當凌絕頂:Java開發(fā)修行實錄
- Python物理建模初學者指南(第2版)
- 從零開始構建深度前饋神經(jīng)網(wǎng)絡:Python+TensorFlow 2.x
- iOS Development with Xamarin Cookbook
- Java程序設計(項目教學版)
- 威脅建模:設計和交付更安全的軟件
- Swift語言實戰(zhàn)晉級(第2版)
- Python程序設計教程
- 實戰(zhàn)圖解MACD波段交易技術