此问题与帖子有关:Keep getting [WDS] Disconnected! error
我已根据答案更新了我的webpack配置设置,但我仍然在控制台中“[WDS] Disconnected!error”。
请提出任何建议?
webpack.config.js
var webpack = require("webpack");
var path = require("path");
module.exports = {
devtool: "inline-source-map",
entry: [
"webpack-dev-server/client?http://127.0.0.0:8080/",
"webpack/hot/only-dev-server",
"./src"
],
devServer: {
contentBase: "./public",
hot: true,
inline: true,
quiet: false,
noInfo: true,
stats: { colors: true }
},
output: {
path: path.join(__dirname, "./public"),
filename: "./assets/js/bundle.js"
},
resolve: {
modulesDirectrories: ["node_modules", "src"],
extentions: ["", ".js"]
},
module : {
loaders: [
{
test: /\.jsx?$/,
exclude: "/node_modules/",
loaders: ["react-hot-loader", "babel?presets[]=react,presets[]=es2015"]
},
{
test: /\.css$/,
loader: "style-loader!css-loader"
},
{
test: /\.gif$/,
loader: "url-loader?mimetype=image/png"
},
{
test: /\.woff(2)?(\?v=[0-9].[0-9].[0-9])?$/,
loader: "url-loader?mimetype=application/font-woff"
},
{
test: /\.(ttf|eot|svg)(\?v=[0-9].[0-9].[0-9])?$/,
loader: "file-loader?name=[name].[ext]"
}
]
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify("development")
}
})
]}
答案 0 :(得分:1)
将transportMode更改为 ws ,而不是“ sock-js.node”:-
devServer: {
transportMode: 'ws',
injectClient: false,
}
答案 1 :(得分:0)
overlay:true
在devServer
对象中再添加一个属性
devServer: {
...
overlay: true,
}
点击此处获取更多信息webpack-dev-server