diff --git a/src/index.js b/src/index.js index 06a6e021..89bef2c3 100644 --- a/src/index.js +++ b/src/index.js @@ -132,39 +132,23 @@ ${hmrCode} const hmrCode = this.hot ? ` if (module.hot) { - module.hot.accept( - ${loaderUtils.stringifyRequest(this, `!!${request}`)}, - function() { - var newContent = require(${loaderUtils.stringifyRequest( - this, - `!!${request}` - )}); - - if (typeof newContent === 'string') { - newContent = [[module.id, newContent, '']]; - } - - var locals = (function(a, b) { - var key, - idx = 0; - - for (key in a) { - if(!b || a[key] !== b[key]) return false; - idx++; + if (!content.locals) { + module.hot.accept( + ${loaderUtils.stringifyRequest(this, `!!${request}`)}, + function () { + var newContent = require(${loaderUtils.stringifyRequest( + this, + `!!${request}` + )}); + + if (typeof newContent === 'string') { + newContent = [[module.id, newContent, '']]; } - - for (key in b) idx--; - - return idx === 0; - }(content.locals, newContent.locals)); - - if (!locals) { - throw new Error('Aborting CSS HMR due to changed css-modules locals.'); + + update(newContent); } - - update(newContent); - } - ); + ) + } module.hot.dispose(function() { update(); diff --git a/test/manual/webpack.config.js b/test/manual/webpack.config.js index ed23eca9..ff431f46 100644 --- a/test/manual/webpack.config.js +++ b/test/manual/webpack.config.js @@ -6,6 +6,7 @@ const ENABLE_SOURCE_MAP = : false; module.exports = { + devtool: ENABLE_SOURCE_MAP ? 'source-map' : false, mode: 'development', output: { publicPath: '/dist/',