Webpack浏览器控制台消息:WDS已断开

时间:2018-12-26 11:09:58

标签: firefox npm webpack webpack-dev-server

此问题仅在Firefox中发生。

我使用webpack设置了一个最小的项目,但在Firefox控制台中不断收到错误

[WDS]已断开连接!

尽管我在网上搜索它,并且有很多建议的解决方案,但不幸的是,没有一个适用于我。我将localhost更改为127.0.0.10.0.0.0,但这些技巧都无效。我更新了npm。也不行。

$ tree
.
├── aaa.js
├── aaa.png
├── index.html
├── package.json
├── package-lock.json
└── webpack.config.js

文件内容:

aaa.js

(empty)

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>my title</title>
</head>
<body>
Hello world!
</body>
</html>

package.json

{
  "name": "react-2",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "webpack-dev-server --open --mode development",
    "build": "webpack"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "html-loader": "^0.5.5",
    "html-webpack-plugin": "^3.2.0",
    "prop-types": "^15.6.2",
    "webpack": "^4.27.1",
    "webpack-cli": "^3.1.2",
    "webpack-dev-server": "^3.1.10"
  }
}

webpack.config.js

const HtmlWebPackPlugin = require("html-webpack-plugin");
const path = require('path');
module.exports = {
  entry: './aaa.js',
  output: {
      path: path.resolve(__dirname, 'dist'),
      filename: 'bundle.js',
  },
  module: {
    rules: [
      {
        test: /\.html$/,
        use: [
          {
            loader: "html-loader"
          }
        ]
      },
    ]
  },
  devServer: {
      host: '127.0.0.1',
      port: 8080,
  },
  plugins: [
    new HtmlWebPackPlugin({
      template: "index.html",
      filename: "./index.html",
      favicon:  "aaa.png"
    })
  ]
};

0 个答案:

没有答案