Skip to content

Commit c483e5a

Browse files
authoredJul 31, 2017
fix($hmr): always require hotModuleReplacement.js in DEV mode so HMR works when there is only 1 CSS module
1 parent 870a848 commit c483e5a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed
 

‎loader.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ var LimitChunkCountPlugin = require("webpack/lib/optimize/LimitChunkCountPlugin"
1515
var NS = fs.realpathSync(__dirname);
1616

1717
module.exports = function(source) {
18-
return source;
18+
if (process.env.NODE_ENV !== 'development') return source
19+
20+
// We need to always require hotModuleReplacement.js for HMR to work in a wierd scenario
21+
// where only one css file is imported. Otherwise HMR breaks when modules are disposed.
22+
return `${source}
23+
require(${loaderUtils.stringifyRequest(this, path.join(__dirname, "hotModuleReplacement.js"))})`;
1924
};
2025

2126
module.exports.pitch = function(request) {

0 commit comments

Comments
 (0)
Please sign in to comment.