我收到以下错误:
[HMR] Waiting for update signal from WDS...
当我在终端
中运行“webpack”时我的webpack config js文件如下:
var webpack = require('webpack');
module.exports = {
entry: [
'webpack-dev-server/client?http://localhost:8080',
'webpack/hot/only-dev-server',
'./src/index.js'
],
module: {
loaders: [{
test: /\.js?$/,
exclude: /node_modules/,
loader: 'react-hot!babel'
}]
},
resolve: {
extensions: ['', '.js']
},
output: {
path: 'dist',
publicPath: '/',
filename: 'bundle.js'
},
devServer: {
contentBase: './dist',
hot: true
},
plugins: [
new webpack.HotModuleReplacementPlugin()
]
};
和我的package.json如下:
{
"name": "hwr",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"babel": {
"presets": [
"es2015",
"react"
]
},
"devDependencies": {
"babel-core": "^6.11.4",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.9.0",
"babel-preset-react": "^6.11.1",
"react-hot-loader": "^1.3.0",
"webpack": "^1.13.1",
"webpack-dev-server": "^1.14.1"
},
"dependencies": {
"history": "^3.0.0",
"react": "^15.3.0",
"react-dom": "^15.3.0",
"react-router": "^2.6.1"
}
}
该错误来自哪里?
答案 0 :(得分:1)
这不是错误,您在Webpack构建中启用了热模块替换(因此[HMR])功能。这只是来自HMR功能的日志消息之一。听起来你不想打开HMR?在这种情况下,您应该从入口点,'webpack-dev-server/client?http://localhost:8080', 'webpack/hot/only-dev-server'
加载器和加载器条目中删除react-hot
条目,从插件new webpack.HotModuleReplacementPlugin()
和开发服务器设置中删除hot: true
。