Files
bedrock/assets/build/util/addHotMiddleware.js
QWp6t 4adbc347c2 Fix browsersync (#1815)
* Update dependencies
* Remove monkey-hot-loader
* Use webpack-merge instead of util/mergeWithConcat()
* Fix: copyglobs plugin `after-emit` is bound twice
* NoErrorsPlugin() is deprecated in favor of NoEmitOnErrorsPlugin()
* webpack-dev-middleware should use same publicPath as compiler
* webpack-hot-middleware/client should be prepended to entries
* Browser should refresh when HMR fails
* Bootstrap package.json has correct main property
Sometime between alpha 2 and 3, package.json was pointing to nonexistent
file, so we referenced file manually in our repo. Underlying issue was
fixed by alpha 4, so we no longer have to specify full path to file.
2017-01-18 23:58:37 -08:00

22 lines
561 B
JavaScript

const qs = require('qs');
/**
* Loop through webpack entry
* and add the hot middleware
* @param {Object} entry webpack entry
* @return {Object} entry with hot middleware
*/
module.exports = (entry) => {
const results = {};
const hotMiddlewareScript = `webpack-hot-middleware/client?${qs.stringify({
timeout: 20000,
reload: true,
})}`;
Object.keys(entry).forEach((name) => {
results[name] = Array.isArray(entry[name]) ? entry[name].slice(0) : [entry[name]];
results[name].unshift(hotMiddlewareScript);
});
return results;
};