I have a node express app that is using socket.io. This app is proxied through webpack's dev server as I want to use hot module replacement in the client side react app (which communicates back to the socket code on the node app.)
If I add my socket.io
listener however it breaks the hot module replacement stuff. I guess because my listener is receiving the messages instead of the hmr listener?
The problem is that when I save a file that would be hot loaded, instead i get the following in chrome dev tools and NO hot load:
[WDS] App updated. Recompiling...
client?eeaa:52 [WDS] Proxy error.
client?eeaa:54 cannot proxy to http://127.0.0.1:1338 (read ECONNRESET)
client?eeaa:90 [WDS] App hot update...
socket.io.js:1456 GET http://localhost:1339/socket.io/?EIO=3&transport=polling&t=LA7JXr9&sid=r1NFzh1HOD5GcbN0AAAA 502 (Bad Gateway)
client?eeaa:25 [WDS] App updated. Recompiling...
client?eeaa:90 [WDS] App hot update...
socket.io.js:1456 POST http://localhost:1339/socket.io/?EIO=3&transport=polling&t=LA7Jckl&sid=r1NFzh1HOD5GcbN0AAAA 400 (Bad Request)
(The body of the 400 (Bad Request)
is:
{"code":1,"message":"Session ID unknown"}
Anyone know how to set this up properly?
MY webpack.config.js
is currently:
var path = require('path');
var webpack = require('webpack');
module.exports = {
entry: [
'webpack-dev-server/client?http://127.0.0.1:1339/',
'webpack/hot/only-dev-server',
'./src/client/main.js'
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'client-bundle.js'
},
resolve: {
modulesDirectories: ['node_modules'],
extensions: ['', '.js']
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loaders: ['react-hot', 'babel']
}, {
test: /\.css$/,
loader: 'style!css'
}
]
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
],
devtool: 'inline-source-map',
devServer: {
hot: true,
proxy: {
'*': 'http://127.0.0.1:' + (process.env.PORT || 1338)
},
host: '127.0.0.1'
}
};