我似乎无法让热重载功能为我正常工作。每当我进行更新时,我都会收到以下错误消息:
获取http://localhost:9090/cd0492f7657672ef15e4.hot-update.json 404(未找到)
[HMR] 无法应用更新。需要完全重新加载!
[HMR](可能是因为重启了 webpack-dev-server)
我很确定这是因为当我去的时候publicPath: '/js/',
我得到一个 404 但是当我去的时候我可以找到文件。gulpfile.js
http://localhost:9090/cd0492f7657672ef15e4.hot-update.json
http://localhost:9090/js/cd0492f7657672ef15e4.hot-update.json
但是publicPath: '/js/'
需要,app.js
所以我不知道如何解决它,有什么想法吗?
webpack.config.js
var webpack = require('webpack');
module.exports = {
cache: true,
entry: ['webpack/hot/dev-server', './resources/assets/app.js'],
output: {
path: __dirname + '/public/js',
publicPath: '/js/',
filename: "scripts.js"
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel'
}
]
}
};
gulpfile.js
...
var webpackConfig = require('./webpack.config.js');
...
gulp.task('webpack-dev-server', function(callback) {
// modify some webpack config options
var myConfig = Object.create(webpackConfig);
myConfig.devtool = 'eval';
myConfig.debug = true;
myConfig.plugins = [
new webpack.HotModuleReplacementPlugin()
];
// Start a webpack-dev-server
new webpackDevServer(webpack(myConfig), {
hot: true,
stats: {
colors: true
},
publicPath: '/js/',
proxy: {
'*': 'http://localhost:8080'
}
}).listen(9090, 'localhost', function(err) {
if (err) throw new gulpUtil.PluginError('webpack-dev-server', err);
});
});