liady / webpack-node-externals

Easily exclude node modules in Webpack
MIT License
1.3k stars 62 forks source link

Noob question: After excluding modules from webpack, how do I get them into my Electron app's node_modules folder? #98

Closed mountaindude closed 3 years ago

mountaindude commented 3 years ago

I am very new to Webpack, have probably missed something obvious. Building an Electron app using vue/cli.

After telling webpack not to include modules in my project's node_modules folder, those modules must instead, somehow, be copied to the Electron build directory's node_modules folder, before the actual Electron app is created. Otherwise the app won't (of course...) run due to missing dependencies.

But what's the best way of doing this? Running npm install or yarn in the build directory, using the package.json there? Copying files from the project's node_modules directory? Seems very primitive...

liady commented 3 years ago

@mountaindude I think that if you're not building for a Node environment (like browser, electron, etc) - it's probably be best to do bundle all your dependencies. So maybe when building for Electron you don't need webpack-node-externals :)

liady commented 3 years ago

@mountaindude closing for now since excluding modules from the bundle is probably not a good strategy for electron apps - I believe that you probably should include them in the bundle.

serdarde commented 1 year ago

Actually, it works very well for Electron's main and preload processes on dev mode. For production, you have to create a very long allow list, or you can use the solution kmjennison mentioned under the issue https://github.com/liady/webpack-node-externals/issues/72.

It makes no sense to use it on for renderer process.