electron-connect
electron-connect copied to clipboard
Help configuring with webpack
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 Did you have any luck getting main and renderer reloads working with webpack?
@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. :).