UNPKG

746 BJavaScriptView Raw
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5module.exports = function addStyleUrl(cssUrl) {
6 if(typeof DEBUG !== "undefined" && DEBUG) {
7 if(typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
8 }
9 var styleElement = document.createElement("link");
10 styleElement.rel = "stylesheet";
11 styleElement.type = "text/css";
12 styleElement.href = cssUrl;
13 var head = document.getElementsByTagName("head")[0];
14 head.appendChild(styleElement);
15 if(module.hot) {
16 return function(cssUrl) {
17 if(typeof cssUrl === "string") {
18 styleElement.href = cssUrl;
19 } else {
20 head.removeChild(styleElement);
21 }
22 };
23 }
24}
\No newline at end of file