Why use webpack with an electron

I am experimenting with an electron. I see many examples of using webpack.

But why use something like webpack? Because, as far as I can tell, electronic media require('module') .

+6
source share
3 answers

This is not a webpack that is used in electron. The require function is part of node.js, which is the basis for the electron.

Additional information on modules in node.js docs: https://nodejs.org/dist/latest-v5.x/docs/api/modules.html

But while the web package is also available as a node module ( https://www.npmjs.com/package/webpack ), it is also possible to use webpack with an electronic one. At this point, you can also use the assembly on the fly in the production process, because node and chrome are available within one application.

Why use webpack with an electron? When you use reaction components or vue.js, it might be a good idea to separate components. To associate your code with one application, you need a browser or web package. This would be, for example, a good reason why to use it.

+5
source

There is no reason to use Webpack in Electron, see electron-compile to use Babel and LESS in Electron.

+8
source

Webpack is not just a collection of JS modules; it can be used to link static assets (for example, built-in base64 images), compile Sass / Less / Stylus / CSS modules, eliminate dead code, tree jitter, etc. With the right bootloader and configuration with active development, only require('any-type-of-file.extension') . However, in my personal experience, moreover, Webpack is valuable because of this dev-server and Hot Module Replacement (HMR), which makes Live Reload feel like something from dark times.

To remind you, you get all the combined power of Gulp / Browserify / Rollup, but with HMR on top, all in one tool (and many, many, many, many, many downloaders;).

Setting up Webpack is PITA, no doubt, but if you plan to work in the Electron application for a sufficient amount of time, then the time saved from the HMR is worth it.

+4
source

All Articles