hot module replacement support
parent
0cb642b1ed
commit
649ffa40e9
|
@ -10,5 +10,9 @@ module.exports = function(cssCode) {
|
|||
} else {
|
||||
styleElement.appendChild(document.createTextNode(cssCode));
|
||||
}
|
||||
document.getElementsByTagName("head")[0].appendChild(styleElement);
|
||||
var head = document.getElementsByTagName("head")[0];
|
||||
head.appendChild(styleElement);
|
||||
return function() {
|
||||
head.removeChild(styleElement);
|
||||
};
|
||||
}
|
|
@ -7,5 +7,9 @@ module.exports = function(cssUrl) {
|
|||
styleElement.rel = "stylesheet";
|
||||
styleElement.type = "text/css";
|
||||
styleElement.href = cssUrl;
|
||||
document.getElementsByTagName("head")[0].appendChild(styleElement);
|
||||
var head = document.getElementsByTagName("head")[0];
|
||||
head.appendChild(styleElement);
|
||||
return function() {
|
||||
head.removeChild(styleElement);
|
||||
};
|
||||
}
|
6
index.js
6
index.js
|
@ -7,9 +7,11 @@ module.exports = function() {};
|
|||
module.exports.pitch = function(remainingRequest) {
|
||||
this.cacheable && this.cacheable();
|
||||
var comment1 = "// style-loader: Adds some css to the DOM by adding a <style> tag\n";
|
||||
var addStyleCode = "require(" + JSON.stringify("!" + path.join(__dirname, "addStyle.js")) + ")\n";
|
||||
var addStyleCode = "var dispose = require(" + JSON.stringify("!" + path.join(__dirname, "addStyle.js")) + ")\n";
|
||||
var comment2 = "\t// The css code:\n";
|
||||
var cssCodeRequest = "require(" + JSON.stringify("!!" + remainingRequest) + ")";
|
||||
return comment1 + addStyleCode + comment2 + "\t(" + cssCodeRequest + ")";
|
||||
var comment3 = "// Hot Module Replacement\n";
|
||||
var hmrCode = "if(module.hot) {\n\tmodule.hot.accept();\n\tmodule.hot.dispose(dispose);\n}";
|
||||
return comment1 + addStyleCode + comment2 + "\t(" + cssCodeRequest + ")\n" + hmrCode;
|
||||
};
|
||||
module.exports.seperable = true;
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "style-loader",
|
||||
"version": "0.5.2",
|
||||
"version": "0.6.0",
|
||||
"author": "Tobias Koppers @sokra",
|
||||
"description": "style loader module for webpack",
|
||||
"licenses": [
|
||||
|
|
Loading…
Reference in New Issue