This repository has been archived by the owner on May 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from timneutkens/master
Pull in latest changes
- Loading branch information
Showing
4 changed files
with
190 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Based on github.com/sheerun/extracted-loader | ||
/* eslint-disable no-irregular-whitespace */ | ||
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 = ${this.options.output.publicPath | ||
? `'${this.options.output.publicPath}'` | ||
: `document.location.protocol + '//' + document.location.host`}; | ||
document | ||
.querySelectorAll("link[href][rel=stylesheet]") | ||
.forEach(function(link) { | ||
if (!link.href.match(prefix) || link.stale) return; | ||
injectCss(link, link.href.split("?")[0] + "?unix=${Number( | ||
new Date() | ||
)}"); | ||
}); | ||
} | ||
} | ||
` | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.