Initial commit

master
Tobias Koppers 2012-04-07 03:06:57 +02:00
commit a73b1e68bc
8 changed files with 65 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
node_modules

14
README.md Normal file
View File

@ -0,0 +1,14 @@
# style loader for webpack
## Usage
``` javascript
require("style!./file.css");
// => add rules in file.css to document
```
Does nothing in node.js.
## License
MIT (http://www.opensource.org/licenses/mit-license.php)

1
addStyle.js Normal file
View File

@ -0,0 +1 @@
module.exports = function() {}

14
addStyle.web.js Normal file
View File

@ -0,0 +1,14 @@
/*
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);
}

13
index.js Normal file
View File

@ -0,0 +1,13 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
var path = require("path");
module.exports = function(content) {
var options = this;
var result = [];
var loaderSign = this.request.indexOf("!");
var rawCss = this.request.substr(loaderSign); // including leading "!"
return "require(" + JSON.stringify(path.join(__dirname, "addStyle")) + ")"+
"(require(" + JSON.stringify(rawCss) + "))";
}

16
package.json Normal file
View File

@ -0,0 +1,16 @@
{
"name": "style-loader",
"version": "0.1.0",
"author": "Tobias Koppers @sokra",
"description": "style loader module for webpack",
"dependencies": {
"raw-loader": "0.1.x"
},
"licenses": [
{
"type": "MIT",
"url": "http://www.opensource.org/licenses/mit-license.php"
}
],
"license": "MIT"
}

3
web-only.loader.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = function(content) {
return "";
}

3
web-only.web-loader.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = function(content) {
return content;
}