style-loader
Advanced tools
Comparing version 0.2.1 to 0.5.0
@@ -1,1 +0,14 @@ | ||
module.exports = function() {} | ||
/* | ||
MIT License http://www.opensource.org/licenses/mit-license.php | ||
Author Tobias Koppers @sokra | ||
*/ | ||
module.exports = function(cssCode) { | ||
var styleElement = document.createElement("style"); | ||
styleElement.type = "text/css"; | ||
if (styleElement.styleSheet) { | ||
styleElement.styleSheet.cssText = cssCode; | ||
} else { | ||
styleElement.appendChild(document.createTextNode(cssCode)); | ||
} | ||
document.getElementsByTagName("head")[0].appendChild(styleElement); | ||
} |
21
index.js
@@ -6,12 +6,15 @@ /* | ||
var path = require("path"); | ||
module.exports = function(content) { | ||
module.exports = function() {}; | ||
module.exports.pitch = function(remainingRequest) { | ||
this.cacheable && this.cacheable(); | ||
this.clearDependencies && this.clearDependencies(); | ||
if(this.loaderType != "loader") throw new Error("style-loader do not work as pre or post loader"); | ||
var rawCss = this.currentLoaders.slice(this.loaderIndex+1).join("!") + "!" + this.filenames[0]; | ||
if(this.web) | ||
return "require(" + JSON.stringify(path.join(__dirname, "addStyle")) + ")"+ | ||
"(require(" + JSON.stringify(rawCss) + "))"; | ||
return ""; | ||
} | ||
var cssCodeRequest = "require(" + JSON.stringify("!!" + remainingRequest) + ")"; | ||
var addStyleCode = "require(" + JSON.stringify("!" + path.join(__dirname, "addStyle.js")) + ")"; | ||
var footer = ""; | ||
if(this.debug) { | ||
footer = "\n\n/* STYLE-LOADER FOOTER */\n/*@ sourceURL=style:///" + | ||
encodeURI(remainingRequest.replace(/^!/, "")).replace(/%5C|%2F/g, "/").replace(/\?/, "%3F").replace(/^\//, "") + " */"; | ||
footer = "+" + JSON.stringify(footer); | ||
} | ||
return addStyleCode + "(" + cssCodeRequest + footer + ")"; | ||
}; | ||
module.exports.seperable = true; |
{ | ||
"name": "style-loader", | ||
"version": "0.2.1", | ||
"version": "0.5.0", | ||
"author": "Tobias Koppers @sokra", | ||
@@ -11,4 +11,3 @@ "description": "style loader module for webpack", | ||
} | ||
], | ||
"license": "MIT" | ||
] | ||
} |
@@ -12,3 +12,3 @@ # style loader for webpack | ||
It's recommended to combine it with the [`css`](https://github.com/sokra/webpack-css-loader) loader: `require("style!css!./file.css")`. | ||
It's recommended to combine it with the [`css`](https://github.com/webpack/css-loader) loader: `require("style!css!./file.css")`. | ||
@@ -15,0 +15,0 @@ ## License |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1899
31
4