美文网首页
webpack-serve,hot热更新不生效

webpack-serve,hot热更新不生效

作者: 一个废人 | 来源:发表于2018-05-24 12:23 被阅读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
          }
        }
      },
      ...
    }
    

    相关文章

      网友评论

          本文标题:webpack-serve,hot热更新不生效

          本文链接:https://www.haomeiwen.com/subject/wktsjftx.html