Webpack plugin for Electron Forge, let's you use a webpack directly in your tooling
Last updated 12 days ago by malept .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @electron-forge/plugin-webpack 
SYNC missed versions from official npm registry.


???? The API of this plugin is not stable could change at any time without following semver.

Please do not use this plugin until this warning has been removed

ℹ️ These docs are incomplete {% endhint %}

The Webpack plugin allows you to use standard Webpack tooling to compile both your main process code and your renderer process code with built in support forHot Module Reloading in the renderer process and support for multiple renderers.


yarn add @electron-forge/plugin-webpack --dev

Basic Usage


You must provide two webpack config files, one for the main process in mainConfig and one for the renderer process' in renderer.config. See an example below:

The complete config options are available at WebpackPluginConfig

  plugins: [
    ['@electron-forge/plugin-webpack', {
      mainConfig: './webpack.main.config.js',
      renderer: {
        config: './webpack.renderer.config.js',
        entryPoints: [{
          html: './src/renderer/index.html',
          js: './src/renderer/index.js',
          name: 'main_window'

Project Setup

You need to do two things in your project files as well in order to make this plugin work.

First, your main entry in your package.json file needs to point at "./.webpack/main" like so:

  "name": "my-app",
  "main": "./.webpack/main",

Secondly, all loadUrl and preload paths need to reference the magical globals that this plugin will define for you for each of your entry points. For an entry point with the name main_window two variables will be defined MAIN_WINDOW_WEBPACK_ENTRY and MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY , this point to the paths for your renderer entry point and your preload script path respectively. An example is given below.

{% code-tabs %}

const mainWindow = new BrowserWindow({
  webPreferences: {


{% endcode-tabs-item %} {% endcode-tabs %}

Hot Reloading

All your renderer processes in development will have hot reloading enabled by default, it is unfortunately impossible to do hot module reloading inside a renderer preload script, WebWorker or for the main process itself. However Webpack is constantly watching and recompiling those files so to get updates for preload scripts simply reload the window, and for the main process just type "rs" in the console you launched electron-forge from and we will restart your app for you with the new main process code.

What happens in production?

In theory, you shouldn't need to care. In development we spin up webpack-dev-server instances to power your renderer processes, in prod we just build the static files. Assuming you use the globals we explained in Project Setup, everything should Just Work(tm) when your app is packaged.

How do I do virtual routing?

If you want to use something like react-router to do virtual routing in your app you will need to ensure you use a history method that is not based on the browser history APIs. Browser history will work in development but not in production as your code will be loaded from the filesystem not a webserver. In the react-router case you should use the MemoryRouter to make everything work.

Current Tags

  • 6.0.0-beta.33                                ...           beta (10 months ago)
  • 6.0.0-beta.46                                ...           latest (12 days ago)

40 Versions

  • 6.0.0-beta.46                                ...           12 days ago
  • 6.0.0-beta.45                                ...           3 months ago
  • 6.0.0-beta.44                                ...           4 months ago
  • 6.0.0-beta.43                                ...           5 months ago
  • 6.0.0-beta.42                                ...           5 months ago
  • 6.0.0-beta.41                                ...           5 months ago
  • 6.0.0-beta.40                                ...           5 months ago
  • 6.0.0-beta.39                                ...           7 months ago
  • 6.0.0-beta.38                                ...           7 months ago
  • 6.0.0-beta.37                                ...           7 months ago
  • 6.0.0-beta.36                                ...           7 months ago
  • 6.0.0-beta.35                                ...           7 months ago
  • 6.0.0-beta.34                                ...           9 months ago
  • 6.0.0-beta.33                                ...           10 months ago
  • 6.0.0-beta.32                                ...           a year ago
  • 6.0.0-beta.31                                ...           a year ago
  • 6.0.0-beta.30                                ...           a year ago
  • 6.0.0-beta.29                                ...           a year ago
  • 6.0.0-beta.28                                ...           a year ago
  • 6.0.0-beta.27                                ...           a year ago
  • 6.0.0-beta.26                                ...           a year ago
  • 6.0.0-beta.25                                ...           a year ago
  • 6.0.0-beta.24                                ...           a year ago
  • 6.0.0-beta.23                                ...           a year ago
  • 6.0.0-beta.22                                ...           a year ago
  • 6.0.0-beta.21                                ...           a year ago
  • 6.0.0-beta.20                                ...           a year ago
  • 6.0.0-beta.19                                ...           a year ago
  • 6.0.0-beta.18                                ...           a year ago
  • 6.0.0-beta.17                                ...           2 years ago
  • 6.0.0-beta.16                                ...           2 years ago
  • 6.0.0-beta.15                                ...           2 years ago
  • 6.0.0-beta.14                                ...           2 years ago
  • 6.0.0-beta.13                                ...           2 years ago
  • 6.0.0-beta.12                                ...           2 years ago
  • 6.0.0-beta.11                                ...           2 years ago
  • 6.0.0-beta.10                                ...           2 years ago
  • 6.0.0-beta.9                                ...           2 years ago
  • 0.0.2                                ...           2 years ago
  • 0.0.1                                ...           2 years ago
Today 1
This Week 1
This Month 361
Last Day 4
Last Week 18
Last Month 226
Dependencies (14)
Dev Dependencies (2)
Dependents (0)

Copyright 2014 - 2016 © taobao.org |