官术网_书友最值得收藏!

  • 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:

  1. 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.
  1. Once the script exits, you should see the prebuilt application, that is, my-first-app.exe, in the dist/win-unpacked folder.
  2. Double-click on the my-first-app.exe file to run the application:
  1. 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
  1. 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:

  1. Now, double-click the installer file. The setup wizard should set up the application and automatically launch it.

Congratulationsyou've got your first cross-platform Electron application package up and running on Windows 10!

主站蜘蛛池模板: 文安县| 宽甸| 寿光市| 康马县| 绥棱县| 龙胜| 郑州市| 石棉县| 久治县| 乐亭县| 馆陶县| 汉中市| 兰西县| 绍兴县| 阿拉善右旗| 兰州市| 黔南| 石林| 聂拉木县| 历史| 巴彦县| 余姚市| 富川| 色达县| 荆州市| 锡林郭勒盟| 新宁县| 济南市| 克什克腾旗| 桃园县| 富顺县| 临安市| 波密县| 寿宁县| 城步| 汝州市| 马龙县| 蛟河市| 美姑县| 车险| 岱山县|