Just stumbled into this problem myself, and thought I could mention that a quick fix is to add an additional entry in your webpack config for your child process (creates a separate bundle for your child process) and then make it use this bundle by some resolve-rules, or simply by string-replace-loader:
Some example webpack config:
module.exports = {
// ...
target: 'node',
entry: {
server: './server/server.js',
daemon: './daemon.js'
},
output: {
path: path.resolve(__dirname, '../serverdist'),
filename: '[name].bundle.js'
},
module: {
rules: [
// ... your other existing rules for building the server code
{
test: /placeWhereYouAreCallingFork.js$/,
loader: 'string-replace-loader',
options: {
search: 'daemon.js',
replace: 'serverdist/daemon.bundle.js'
}
}
]
}
// Other webpack stuff...
};
This depends on the replace loader:
npm install --save-dev string-replace-loader
Maybe not the cleanest solution but it it worked for me, and I thougth it was quite simple.
child_process.fork()
– Crimson