Simon H
Simon H

Reputation: 21005

Electron-forge with webpack devServer

I have created an app with electron-forge using npx create-electron-app electron --template=webpack.

I then did npm install webpack-dev-server

In my webpack.renderer.config.js I started to add a devServer section with proxy and before sections, but when I use npm run start these are ignored.

npm run start runs electron-forge start and that's where I think the problem is as I do not have direct access to the webpack call so as to get webpack serve ...

What is needed to get the webpack dev-server running with electron?

Upvotes: 2

Views: 3497

Answers (1)

J4Y-M
J4Y-M

Reputation: 378

webpack-dev-server is already used by Electron-Forge, as indicated in Electron-forge Webpack documentation

In development we spin up webpack-dev-server instances to power your renderer processes, in prod we just build the static files.

For renderer : it refresh for you. For main, as indicated in the documentation, you have to type "rs" in the terminal to "reload" the app.

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.

If you want to access the webpack log server : http://localhost:9000/ (9000 is the default loggerPort in plugins-webpack config)

// forge.config.js (or package.json)
 plugins: [
    ['@electron-forge/plugin-webpack',
      {
        // Renderer server port
        port: 3000,
        //  Webpack logger port
        loggerPort: 9000,
        mainConfig: './webpack...',
        ...
      }
     ],

Upvotes: 6

Related Questions