-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathindex.js
37 lines (36 loc) · 1.09 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
module.exports = function (source) {
if (source.match('module.hot')) {
return source
}
return (
source +
`;
if (module.hot) {
var injectCss = function injectCss(prev, href) {
var link = prev.cloneNode();
link.href = href;
link.onload = link.onerror = function() {
prev.parentNode.removeChild(prev);
};
prev.stale = true;
prev.parentNode.insertBefore(link, prev.nextSibling);
};
module.hot.dispose(function() {
window.__webpack_reload_css__ = true;
});
module.hot.accept();
if (window.__webpack_reload_css__) {
module.hot.__webpack_reload_css__ = false;
console.log("[HMR] Reloading stylesheets...");
var prefix = document.location.protocol + '//' + document.location.hostname;
document
.querySelectorAll("link[href][rel=stylesheet]")
.forEach(function(link) {
if (!link.href.match(prefix) || link.stale) return;
injectCss(link, link.href.split("?")[0] + "?unix=${+new Date()}");
});
}
}
`
)
}