Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should i exclude all node_modules in electron-packager

I'm using electron-packager for creating an electron.exe of my app. I need to exclude all node modules . I tried the following

--ignore=node_modules

The above is not working. Any idea how to exclude all folders/ remove node modules in final build.

like image 217
arun thatham Avatar asked Mar 23 '18 09:03

arun thatham


People also ask

Do I need to push node_modules in production?

No, You don't need to push your node_modules folder to production whether it is a static export or dynamic build. When you export a static build the source file is converted into HTML & js files. So there is no need for node modules on production env.

What does node_modules folder contain?

The node_modules folder contains every installed dependency for your project. In most cases, you should not commit this folder into your version controlled repository. As you install more dependencies, the size of this folder will quickly grow. Furthermore, the package-lock.

Can you use node modules in electron?

The node-pre-gyp tool provides a way to deploy native Node modules with prebuilt binaries, and many popular modules are using it. Sometimes those modules work fine under Electron, but when there are no Electron-specific binaries available, you'll need to build from source.


1 Answers

If you install modules as devDependencies, they will all be pruned automatically before packaging.

If you're using electron-builder you can define glob patterns as files in the config. In this case !**/node_modules/* will exclude all of node_modules.

If you're using electron-packager you can use the ignore option and regular expression to exclude files.

like image 108
Tim Avatar answered Nov 23 '22 18:11

Tim