electron-connect icon indicating copy to clipboard operation
electron-connect copied to clipboard

Help configuring with webpack

Open michaeljota opened this issue 8 years ago • 2 comments

Hi! Thanks for develop this tool. I'm trying to use this with webpack, and I successfully had setup basic reload. However, I would like some additional task to be handle. This is my actual file:

/*
 * @author: @michaeljota
 */

const appRoot = require('app-root-path');

const mainThreadConfig = require('./main'); // Resolve the Webpack config file for the main thread.
const rendererThreadConfig = require('./renderer'); // Resolve the Webpack config file for the renderer thread.

const webpackMerge = require('webpack-merge');
const { server, client } = require('electron-connect');

const electron = server.create({ path: appRoot.resolve('dist') }); // Create the server in the output folder

/*
 * Webpack Plugins
 */
const { ProvidePlugin } = require('webpack');
const WebpackOnBuildPlugin = require('on-build-webpack');

module.exports = (env) => {
  let started = false;

  return [
    // The Electron main thread configuration
    webpackMerge(mainThreadConfig(env), {
      plugins: [
        new WebpackOnBuildPlugin(function (stats) {
          if (!started) {
            started = true;
            electron.start();
          } else {
            electron.restart();
          }
        }),
        new ProvidePlugin({
          livesyncClient: client,
        }),
      ],
    }),
    // The Electron renderer thread configuration
    webpackMerge(rendererThreadConfig(env), {
      plugins: [
        new WebpackOnBuildPlugin(function (stats) {
          if (started) {
            electron.reload();
          }
        }),
      ],
    }),
  ];
};

What I want it's to the electron-connect to only reload the renderer thread when the renderer files changes, and the reload the whole application when the main files changes.

It's that posible? Thanks you.

michaeljota avatar Nov 03 '16 01:11 michaeljota

@michaeljota Did you have any luck getting main and renderer reloads working with webpack?

rob3c avatar Dec 12 '16 21:12 rob3c

@rob3c nop. That's all I got. I think this maybe have do to with Webpack life cycle, other than with Electron itself. However, I have not try any other setup. If you find something, pingme here. :).

michaeljota avatar Dec 13 '16 05:12 michaeljota