我环顾四周,但无法获得我在工作中看到的任何答案。Webpack - [HMR]热模块更换已禁用
我无法使用webpack或webpack开发服务器的命令行;我仅限于使用Node API。
以下是我如何使用webpack。包含在一饮而尽任务
webpack.config.js
module.exports = {
entry: [
'webpack-dev-server/client?http://localhost:3000',
// i've also tried webpack/hot/dev-server here
'webpack/hot/only-dev-server',
path.join(__dirname, 'src', 'js', 'app.jsx')
],
output: {
path: path.join(__dirname, 'dist', 'js'),
filename: 'script.js',
publicPath: '/dist/'
},
module: {
loaders: [{
test: /\.(js|jsx)$/,
loaders: ['react-hot', 'babel']
}]
},
plugins: []
};
“开始”
gulp.task('start', function (callback) {
var config = Object.create(require('webpack.config.js'));
config.plugins.push(new webpack.HotModuleReplacementPlugin());
var devServer = new webpackDevServer(webpack(config), {
stats: { colors: true },
contentBase: path.resolve(__dirname, 'dist'),
progress: true,
inline: true,
hot: true
});
});
我希望
什么,当我运行一饮而尽开始,我期望webpack dev服务器能够启动,允许我打本地主机:3000 /。这应该从我的项目的/ dist /文件夹加载一个index.html。到现在为止还挺好。我期望在对文件进行更改时(例如,app.jsx),会发生更改。
什么是真正发生
我收到错误“[HMR]热模块的更换已停用”,没有进一步的解释。
任何帮助,将不胜感激。我一直试图让热重装工作一整天。
谢谢,但这也没有奏效。 –