electron-packager

electron-packager 构建的所有可执行文件都放置在 build 目录

编译为全系统平台通用

并不是所有平台都可以编译支持所有其他平台.

  1. npm run build

编译指定系统平台

当前已支持 darwin, mas, linuxwin32.

  1. # build for darwin (macOS)
  2. npm run build:darwin

清空

删除 build 目录所有已编译内容

  1. npm run build:clean

Windows 用户

如果打算在 非Windows 平台编译支持 Windows 执行程序, 你必须安装 wine. 查看更多信息.

默认配置

可以参考文档来获取关于如何修改 .electron-vue/build.config.js 来进行自定义/更详细的配置. 最终生成的 可执行文件名是在你的 package.jsonproductName 设置好的.

  1. {
  2. // Target 'x64' architecture
  3. arch: 'x64',
  4. // Compress app using 'electron/asar'
  5. asar: true,
  6. // Directory of the app
  7. dir: path.join(__dirname, '../'),
  8. // Set electron app icon
  9. // File extensions are added based on platform
  10. //
  11. // If building for Linux, please read
  12. // https://github.com/electron-userland/electron-packager/blob/master/docs/api.md#icon
  13. icon: path.join(__dirname, '../build/icons/icon'),
  14. // Ignore files that would bloat final build size
  15. ignore: /(^\/(src|test|\.[a-z]+|README|yarn|static|dist\/web))|\.gitkeep/,
  16. // Save builds to `builds`
  17. out: path.join(__dirname, '../build'),
  18. // Overwrite existing builds
  19. overwrite: true,
  20. // Environment variable that sets platform
  21. platform: process.env.BUILD_TARGET || 'all'
  22. }