Search code examples
javascriptelectronelectron-packager

How to manage your files in Electron app when packaging?


I am working with Electron and when I want to run my package I use the npm start command or a more advance command to start a specific build. ex for windows.

In my package.json I only call for the basic main.js and index.html. In the main.js file I use FS to work with the file system.

Here is my project directory three before build :

/project Folder
  /assets
    /css
    /icons
      /win
      /png
      /mac
 index.html
 main.js
 other.js

When I package my app it creates an executable file in a new directory inside my project folder. Now I'm not sure what electron does here.

If I remove other.js file from the project folder my app still run like it should. Is Electron packing all my files into something else?


Solution

  • Well Today I can answer this question.

    When I run the command to create the executable file. Electron create a package with all you code inside it. So the files that were there when packed, are packed with it.

    But I still can access other files relative to the system file path within the app. Files that are created by the app or files that user can add to the app. will be accessible via system path. The other files that where all inside you build folder are packed in so you don't have to look for them.