I have been using the electron-forge webpack plugin to create a packaged bundle. My main process uses node modules. I have followed the webpack plugin documentation and have set up webpack.main.config and webpack.renderer.config according to the provided template. I have included a dmg maker in the forge.config file, and am able to create a dmg file after an 'npm run make'. However, when running the application, the modules in my node_modules folder (eg httpProxy) can't be accessed via a require. Node modules incorporated into node (eg path) can be accessed. Is there something I can add to webpack.main.config that might enable this access? I have specified the @vercel/webpack-asset-relocator-loader and @grumpy/webpack-node-loader (needed this for a .node file).
Here is my webpack.main.config file:
const webpack = require('webpack');
const nodeExternals = require('webpack-node-externals');
module.exports = {
plugins: [
new webpack.IgnorePlugin({ resourceRegExp: /osx-temperature-sensor$/}),
],
/**
* This is the main entry point for your application, it's the first file
* that runs in the main process.
*/
entry: './main.js',
resolve: {
modules: ['node_modules'],
extensions: ['.js']
},
externals: [nodeExternals()],
// Put your normal webpack config below here
module: {
//rules: require('./webpack.rules'),
rules: [
{
test: /[/\\]node_modules[/\\].+\.(m?js|node)$/,
parser: { amd: false },
use: {
loader: '@vercel/webpack-asset-relocator-loader',
options: {
outputAssetBase: 'native_modules',
},
},
},
{
test: /\.node$/,
loader: '@grumpy/webpack-node-loader'
}
]
},