我正在尝试运行一个简单的webpack-dev-server,如果相关的源文件已经更改,则在请求时编译.bundle.js文件。我不想在此时启用热模块替换(HMR)。
我让服务器正常工作,但是它会将以下错误打印到JavaScript控制台:
GET https://monkey.transposit.com:3000/sockjs-node/info?t=1486581439029 net::ERR_CONNECTION_CLOSED
AbstractXHRObject._start @ home.bundle.js:3182
(anonymous) @ home.bundle.js:3071
[WDS] Disconnected!
log @ home.bundle.js:3684
close @ home.bundle.js:3753
sock.onclose @ home.bundle.js:3980
EventTarget.dispatchEvent @ home.bundle.js:2917
(anonymous) @ home.bundle.js:6021
GET https://monkey.transposit.com:3000/sockjs-node/info?t=1486581439029 net::ERR_CONNECTION_CLOSED
AbstractXHRObject._start @ home.bundle.js:3182
(anonymous) @ home.bundle.js:3071
GET https://monkey.transposit.com:3000/sockjs-node/info?t=1486581440063 net::ERR_CONNECTION_CLOSED
AbstractXHRObject._start @ home.bundle.js:3182
(anonymous) @ home.bundle.js:3071我不清楚浏览器试图做什么,我看到了这些错误。(特别是因为这些包正在编译并成功地服务)。
这是我的webpack.config.js
const path = require('path');
module.exports = {
entry: {
project_console: './src/console/console',
…
},
output: {
filename: '[name].bundle.js',
path: path.join(__dirname, 'dist'),
publicPath: '/js/',
library: '[name]',
libraryTarget: 'var'
},
module: {
rules: [
{test: /\.js$/, use: ['babel-loader'], include: path.join(__dirname, 'src')},
{test: /\.scss/, use: ['style-loader', 'css-loader', 'sass-loader']}
]
},
devServer: {
host: '0.0.0.0',
port: 3000,
hot: false
}
};这是我的package.json
{
…
"files": [
"src/"
],
"scripts": {
"start": "webpack-dev-server”,
…
},
"dependencies": {
"react": "^15.4.2",
"react-dom": "^15.4.2”,
…
},
"devDependencies": {
"webpack": "^2.2.1",
"webpack-dev-server": "^2.3.0”,
…
}
"babel": {
"presets": [
"es2015",
"react"
]
}
…
}谢谢你的帮助!
发布于 2017-02-22 22:53:04
我在调用webpack开发服务器时添加了--no-line,这解决了我的问题。
这是我的package.json
{
"scripts": {
"start": "webpack-dev-server --no-inline”,
…
}
}发布于 2019-01-21 04:00:15
您可以将hotreload=false放在查询字符串中的任何位置,甚至#hotreload=false也能工作。
你仍然会得到:
WDS应用程序更新。重新编译..。
在控制台日志中,但是页面实际上不会重新加载。
这种行为可能会发生变化。我是通过在我的WDS文件中搜索vendor.js文件并向后工作找到它的:-)
发布于 2021-11-20 08:26:10
https://stackoverflow.com/questions/42121991
复制相似问题