Electron-forge with webpack devServer
Asked Answered
S

1

2

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?

Sipe answered 1/4, 2021 at 12:0 Comment(0)
F
6

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...',
        ...
      }
     ],
Farl answered 3/5, 2021 at 13:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.