Answer the question
In order to leave comments, you need to log in
How to enable HMR support in webpack?
Hello. I decided to start using webpack for:
1) generating initial data for the public (minification, sprites, etc.)
2) using hot module replacement.
3), etc.
There were difficulties when using HMR, the page is completely reloaded.
HMR] Cannot apply update. Need to do a full reload!
[HMR] Error: Aborted because 76 is not accepted
...
Uncaught RangeError: Maximum call stack size
exceeded
webpackHotUpdate(0,{
/***/ 76:
/***/ function(module, exports) {
console.log('test');
/***/ }
})
//# sourceMappingURL=0.a2c058c04b843eab955f.hot-update.js.map
var webpack = require("webpack"),
ExtractTextPlugin = require("extract-text-webpack-plugin"),
PathRewriterPlugin = require('webpack-path-rewriter');
module.exports = {
devtool: 'source-map',
entry: {
app: [
'webpack-dev-server/client?http://localhost:8080',
'webpack/hot/dev-server',
'./src/bundle.js'
]
},
output: {
path: '/public/',
filename: '[name].js'
},
module: {
loaders: [{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel"
}, {
test: /\.scss$/,
loader: ExtractTextPlugin.extract("style", "css!sass!autoprefixer")
}, {
test: /\.(png|jpg)$/,
loader: "url?limit=3000&name=[name].[ext]?[hash]"
}, {
test: /.jade$/,
loader: PathRewriterPlugin.rewriteAndEmit({
name: 'index.html',
loader: 'jade-html?' + JSON.stringify({
pretty: true
}),
includeHash: true
})
}]
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new ExtractTextPlugin('[name].css', {
allChunks: true,
disable: process.env.NODE_ENV == 'development'
}),
new PathRewriterPlugin(),
new webpack.NoErrorsPlugin()
]
};
// Js
require('./js/index.js');
// Jade
require('./jade/index.jade');
console.log('test');
doctype html
html
head
meta(charset='utf-8')
title(v-text='title')
meta(name='viewport', content='width=device-width, initial-scale=1, user-scalable=no')
link(href='', media='all', rel='stylesheet')
script(src='')
body
.div Тест
Answer the question
In order to leave comments, you need to log in
How do you run webpack? By chance, don't you add `--hot`? The error looks like two HotModuleReplacement plugins.
Here, look at the issue about HMR, learn.javascript.ru/webpack-screencast , maybe it will remove questions?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question