1
我试图运行一个简单的webpack-dev-server
编译.bundle.js文件时,如果相关源JavaScript文件已被更改请求。我不想在此时启用热模块更换(HMR)。WebPack禁用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"
]
}
…
}
感谢您的帮助!
尝试设置'hot'为false:https://webpack.github.io/docs/webpack-dev-server.html#webpack-dev- server-cli – lux
@lux我在'* devServer.hot * * webpack.config.js *中将'hot'设置为false。你是这个意思吗? –