forked from webpack/style-loader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddStyleUrl.js
More file actions
24 lines (24 loc) · 723 Bytes
/
addStyleUrl.js
File metadata and controls
24 lines (24 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
module.exports = function addStyleUrl(cssUrl) {
if(typeof DEBUG !== "undefined" && DEBUG) {
if(typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
}
var styleElement = document.createElement("link");
styleElement.rel = "stylesheet";
styleElement.type = "text/css";
styleElement.href = cssUrl;
var head = document.getElementsByTagName("head")[0];
head.appendChild(styleElement);
if(module.hot) {
return function(cssUrl) {
if(typeof cssUrl === "string") {
styleElement.href = cssUrl;
} else {
head.removeChild(styleElement);
}
};
}
}