webpack-serve,hot热更新不生效

2018-05-24  本文已影响44人  一个废人

在webpack-serve中,hot热更新不生效,控制台报错:

WebSocket connection to 'ws://0.0.0.0:8081/' failed: Connection closed before receiving a handshake response

然后查资料,解决了次问题,具体原因得以后分析,摘录于下方:

原文地址:https://github.com/webpack-contrib/webpack-serve/issues/56

==========================================
@jonesnc the issue seems to be resolved with this #34.

I use "webpack-serve": "^0.3.1" in the package.json:

{
  "name": "app",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "start": "LOCAL_IP=`hostname -i` webpack-serve --config ./webpack.config.js --mode 'development'",
    ...
  },
  "devDependencies": {
    ...
    "webpack-serve": "^0.3.1"
  },
  ...
}

with the following webpack.config.js:

module.exports = {
  ...
  serve: {
    host: '0.0.0.0',
    hot: {
      host: {
        server: '0.0.0.0',
        client: process.env.LOCAL_IP
      }
    }
  },
  ...
}
上一篇下一篇

猜你喜欢

热点阅读