The method of reducing the volume of the packaged items as react-electron

 

After a react-electron do the project can start packing, the first is packaged react, this naturally goes without saying, but prior to remember that the main project directory file main.js the best process in the root directory, then execute package command

npm run build

  This time the directory structure should look like this

This time should be emphasized that, react to complete the project has been packaged, this time can be up and running on our project alone main.js primary process and build file folders, in other words, the rest of the file and there is no packages electron relationship, or even directly deleted, but after all, is the project source code is certainly not recommended deleted, then you can easily create a new folder, the files and build main.js copy the folder in the past, package.json best be copied over

Then at this time package.json file dependencies inside certainly left plenty in the development process-dependent retention, which is then packaged a great volume of the main reasons. The solution is rude, just delete this one inside the data become so

"DevDependencies" which is also deleted

This time in a new folder in installation time and electron relevant, you only used to get in the main process in main.js dependent (this step is very important, in fact, that white is like in a new folder to initiate a project, like electron)

npm install electron -dev-save
npm install electron-store -dev-save
....

  Then install Strapping Tools

npm install electron-packager -dev-save-g

  Then start packing Note: console must be packaged when run as an administrator, or will be error

electron-packager ./ HHH--win32 --out   --electron-version 5.0.4" 

  Explain this command:

./ directory of your project (Note that this new folder, rather than that you react-electron full project folder, a mistake naught)

HHH generated package name

--win32 packed platform

The rest are some optional configuration, you can see a detailed electron-packager official

Then packaged completed at this time out of the package is only about 150M folder, then use the software to make the relevant packaged into exe installation package, the volume is expected to be compressed to less than 100M

Guess you like

Origin www.cnblogs.com/zxh2459917510/p/11241726.html