The electron packaged into Setup

1, the installationelectron-winstaller

  npm install --save-dev electron-winstaller

2, create a build.js

var electronInstaller = require('electron-winstaller');
var path = require("path");
 resultPromise = electronInstaller.createWindowsInstaller({
  appDirectory: path.join('./out/haha-win32-x64'), //入口
  outputDirectory: path.join('./tmp/build/installer64'),     //出口
  authors: 'yyt',
  exe: 'haha.exe', // name
  setupIcon: path.join ( 'icon.ico'), // Setup icon must be local
  iconUrl: 'http://pm72qibzx.bkt.clouddn.com/icon.ico',// program icon, url must
  noMsi: true,
});
resultPromise.then(() => console.log("It worked!"), (e) => console.log(`No dice: ${e.message}`));

3, installation Electron -squirrel -startup

  npm i electron-squirrel-startup --save

4, main.js add the following code    

if(require('electron-squirrel-startup')) return;

5, execute the command

  npm run packager

  node build.js

 

Guess you like

Origin www.cnblogs.com/ancms/p/11957689.html