Build for production questions (using npm + webpack)


#1

When I build my Electron app for production I still get a node_modules folder with the dependencies. The folder is constituted by:
1-The dependencies which are installed via package.json I already noticed that I can just delete them from the folder (since their code is inside webpack bundle.js )
2-ffprobe-static, which actually occupies the largest amount with 40Mb
3-The nodejs modules such as ajv,deferential, debug, decamelize, etc (158 folders total, while I don’t even know most of them, let alone use them directly)

Regarding 2: Is it mandatory to have the binary for ffprobe-static? Can I use ffprobe-static with the ffmpeg.dll given alongside Electron binary?

Regarding 3: Why do I need these and how can I get rid of them? Also, Electron binary already comes with an 18.9Mb node.dll file. Again, can’t I use this instead of having again the node_modules?


#2

Hi there, so to answer some of your questions, in reverse order:

  1. node.dll is the actual node.js engine which executes the code inside your application. node_modules contains the dependencies of your application - npm now tries to move all dependencies (recursively, so also dependencies of your dependencies) to the top level of that folder. You need them both.

  2. You can perform the download of binaries from your application when running on client’s computer. I created a library that allows you to do exactly that: https://www.npmjs.com/package/ffbinaries

  3. You probably want to set it up as an exclusion when building your app.