dev-client.js
1.01 KB
const hotClient = require('webpack-hot-middleware/client?dynamicPublicPath=true&path=__webpack_hmr&noInfo=true&reload=true'); // eslint-disable-line
hotClient.subscribeAll(event => {
if (event.action === 'built') {
document.querySelectorAll('link[href][rel=stylesheet]').forEach((link) => {
fetch(link.href).then((res) => {
res.text().then(text => {
let head = document.getElementsByTagName('head')[0];
let style;
style = document.getElementById(link.href);
if (!style) {
style = document.createElement('style');
style.type = 'text/css';
style.id = link.href;
style.appendChild(document.createTextNode(text));
} else {
style.textContent = text;
}
head.appendChild(style);
});
});
});
}
});