Reputation: 1022
Electron uses main.js as the starting point of application. However, if that file contains all code which handles events of the main process, it is too long and too hard to maintain. Can I split main.js file? and how do I do?
Upvotes: 2
Views: 3999
Reputation: 1022
Finally, I reached my expectation. Firstly, I imported my module at main.js by using require() method. Secondly, I used ipcMain and ipcRender to create communication channel between main process and render process.
My modules is independent of main.js so I still need to import Electron module normally.
Upvotes: 0
Reputation: 14837
You can split up your code into CommonJS modules which are described at depth in the Node docs.
Upvotes: 3