Webpack Dev Server适用于除Chrome以外的所有浏览器?

时间:2017-04-03 20:00:36

标签: javascript reactjs webpack

我已经使用以下设置设置了webpack dev服务器,它在Firefox和Safari上运行正常,但在Chrome上无法正常工作。

我收到此消息:

无法访问此网站

localhost拒绝连接。 在Google上搜索localhost 3005 ERR_CONNECTION_REFUSED

webpack.config.js

const webpack = require('webpack');
const nodeEnv = process.env.NODE_ENV || "production";

module.exports = {
    entry: {
        filename: "./index.js"
    },
    output: {
        filename: "./build/bundle.js"
    },
    module: {
        loaders: [
            {   test: /\.js$/,
                exclude: /node_modules/,
                loader: "babel-loader",
                query: {
                    presets: ['es2015', 'react']
                }
            }
        ]
    },
    devServer: {
        inline: true,
        contentBase: "public",
        port: 3005
    }
}

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,并通过在我的hosts文件中添加新注册表来解决此问题:

  • 使用带有sudo特权的文本编辑器打开/etc/hosts
  • 将此行添加到文件中:

127.0.0.1 localhost