I'm attempting to configure electron-webpack's renderer build settings so that they work in a browser window set up with nodeIntegration
set to false. This means that node APIs aren't available, which is causing the following problems:
webpack seems to be assuming that there is an implementation of
require
already available so isn't including its own in the produced bundle, but instead is simply adding the bundled definitions intomodule.exports
(causing an error thatmodule
isn't defined when the bundle is loaded)html-webpack-plugin
is being used to produce the index.html file, and is adding<script>require("source-map-support/source-map-support.js").install()</script>
to the output, before the bundle is loaded. This line needs to be moved to after the bundle load line, but don't see any way of doing this.
I've tried setting up the following in my package.json
:
"electronWebpack": {
"renderer": {
"webpackConfig": "renderer.additions.webpack.js"
}
}
with the renderer.additions.webpack.js
file containing:
module.exports = {
target: 'web', // node integration is turned off, so use standard web settings.
externals: ['electron'] // do not rely on ability to load code externally: only specifically known-preloaded modules are to be excluded from the package
}
but this doesn't seem to have changed anything at all. Any suggestions how to make this work?