0
使用express
4.14.0,webpack
1.14.0 w/babel
和預設值。這是我的樣板webpack
配置我在什麼地方找到:無法關閉webpack HMR
var path = require('path');
module.exports = {
entry: './main.js',
output: { path: __dirname, filename: 'bundle.js' },
module: {
loaders: [
{
test: /.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['es2015', 'react']
}
}
]
},
};
bundle.js
由快遞送達和我app.js
使用express-generator
生成:
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var app = express();
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'pug');
// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
// catch 404 and forward to error handler
app.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});
// error handler
app.use(function(err, req, res, next) {
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {};
// render the error page
res.status(err.status || 500);
res.render('error');
});
module.exports = app;
我只包括app.js
的內容表明,就正如我所見,沒有任何參考HMR。
我像往常一樣運行nodemon bin/www
和webpack -d --watch
並且在我甚至在我的瀏覽器中打開頁面之前,一直在向/__webpack_hmr
發出一致的請求並獲得404。我該如何解決這個問題?
歡迎來到StackOverflow。您可能想考慮提供一個代碼示例或擴展您的答案,以幫助最廣泛的受衆並鼓勵提升。 [「簡潔是可以接受的,但更全面的解釋更好。」](http://stackoverflow.com/help/how-to-answer) – gfullam