{"id":20753,"library":"webpack-electron-reload","title":"webpack-electron-reload","description":"Webpack plugin that automatically restarts the Electron main process when webpack recompiles. Version 1.0.1, no recent updates. It is a lightweight alternative to electron-reload-webpack-plugin, requiring Electron as a peer dependency. The plugin is used with webpack's watch mode and integrates into the webpack build lifecycle. Suitable for development workflows where quick iteration on the Electron main process is needed.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":"git@github.com:tverdohleb/webpack-electron-reload","tags":["javascript","electron","webpack","webpack-plugin","plugin","live-reload","typescript"],"install":[{"cmd":"npm install webpack-electron-reload","lang":"bash","label":"npm"},{"cmd":"yarn add webpack-electron-reload","lang":"bash","label":"yarn"},{"cmd":"pnpm add webpack-electron-reload","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required to spawn/restart Electron process; must be installed separately","package":"electron","optional":false}],"imports":[{"note":"The package exports a factory function that must be called with options immediately; the return value is the actual plugin constructor.","wrong":"import ElectronReloadPlugin from 'webpack-electron-reload'; // causes runtime error because the export is a factory function","symbol":"ElectronReloadPlugin (default export as a factory function)","correct":"const ElectronReloadPlugin = require('webpack-electron-reload')({ path: '...' });"},{"note":"The factory function returns a plugin class; instantiate it with 'new' or simply call it (it returns a new instance).","wrong":"plugins: [ ElectronReloadPlugin ] // forgetting to call the factory function will pass the factory instead of plugin instance","symbol":"Plugin usage in webpack config","correct":"plugins: [ ElectronReloadPlugin() ]"},{"note":"Only a default export exists; it is a function that takes options and returns a plugin class.","wrong":"import { ElectronReloadPlugin } from 'webpack-electron-reload'; // named export does not exist","symbol":"ESM import (experimental or with bundler)","correct":"import webpackElectronReload from 'webpack-electron-reload';\nconst ElectronReloadPlugin = webpackElectronReload({ path: '...' });"}],"quickstart":{"code":"// webpack.config.js\nconst path = require('path');\nconst ElectronReloadPlugin = require('webpack-electron-reload')({\n  path: path.join(__dirname, './dist/main.js'),\n});\n\nmodule.exports = {\n  target: 'electron-main',\n  entry: './src/main.js',\n  output: {\n    path: path.resolve(__dirname, 'dist'),\n    filename: 'main.js',\n  },\n  plugins: [\n    ElectronReloadPlugin(),\n  ],\n};\n\n// Run with: webpack --watch","lang":"javascript","description":"Shows how to add the plugin to webpack config with path to Electron entry point, then run webpack in watch mode."},"warnings":[{"fix":"Use path.join(__dirname, './dist/main.js') or path.resolve('./dist/main.js') for reliable absolute path.","message":"Path option must be absolute or relative to project root; relative paths are resolved from process.cwd().","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Ensure Electron is started manually for the first build or use a script that starts webpack and electron sequentially.","message":"The plugin only restarts Electron when webpack recompiles; it does not trigger a restart on initial build.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Always call the require result immediately with options: const pluginFactory = require('webpack-electron-reload')(options);","message":"The plugin's factory function must be called with options at import time (not lazily), otherwise the plugin will not work.","severity":"breaking","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use: const pluginFactory = require('webpack-electron-reload')({path: '...'});  plugins: [ pluginFactory() ];","cause":"Forgetting to call the factory function with options before instantiating.","error":"ElectronReloadPlugin is not a constructor"},{"fix":"Ensure the output file exists before webpack watch starts, or use a build step that compiles before watch.","cause":"The path option points to a non-existing file (electron entry point not built yet).","error":"ENOENT: no such file or directory, stat '.../dist/main.js'"},{"fix":"Run 'npm install electron --save-dev' (or '--save') as the package requires Electron as a peer dependency.","cause":"Electron is not installed or not in node_modules.","error":"Cannot find module 'electron'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}