When I compile my Electron application with the npm package "Electron-reload". I got an error. Apprently, Electron-reload use chokidar to watch my applications files, so It can reload it when a file change is detected.
The error I have when compiling my electron main process with webpack :
WARNING in ./node_modules/chokidar/lib/fsevents-handler.js
Module not found: Error: Can't resolve 'fsevents' in
'C:\[...]\node_modules\chokidar\lib'
And the error I have when my electron application is running :
TypeError: Cannot read property 'filename' of undefined
at Object.eval (webpack:///./node_modules/electron-reload/main.js?:12:32)
at eval (webpack:///./node_modules/electron-reload/main.js?:86:30)
at Object../node_modules/electron-reload/main.js (C:\[...]\Dist\Electron\app.js:322:1)
at __webpack_require__ (C:\[...]\Dist\Electron\app.js:20:30)
at eval (webpack:///./Electron/app.ts?:5:5)
at Object../Electron/app.ts (C:\[...]\Dist\Electron\app.js:109:1)
at __webpack_require__ (C:[...]\Dist\Electron\app.js:20:30)
at C:\[...]\Dist\Electron\app.js:84:18
at Object.<anonymous> (C:\[...]\Dist\Electron\app.js:87:10)
at Module._compile (internal/modules/cjs/loader.js:1145:30)
I can't find anything useful online from Electron-reload, chokidar or webpack. Here is my webpack.config.js
const path = require('path');
module.exports = {
mode: "development",
entry: "./Electron/app.ts",
target: "electron-main",
module: "es6",
watch: true,
stats: 'minimal',
output: {
path: path.resolve(__dirname, "./Dist/Electron/"),
filename: "app.js",
},
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
include: /Electron/,
},
]
},
resolve: {
extensions: ['.ts', '.tsx', '.js']
}
}
thank you for your help.
Okay, I didn't resolved the original problem. But since I only wanted to reload my electron render process when a file is changed, I found another way of doing it without "Electron-Reload"
Inside the function that render my main window I added :
Everything is working fine now.