style loader for webpack with SSR support
 
 
Go to file
Tobias Koppers 09a09e8010 0.8.2 2014-11-03 23:24:16 +01:00
fixtures support an array of items with id 2014-09-07 22:23:54 +02:00
.gitignore support an array of items with id 2014-09-07 22:23:54 +02:00
.npmignore Add .npmignore 2014-10-06 22:51:13 +07:00
README.md added documentation for singleton query param 2014-11-03 22:53:02 +01:00
addStyleUrl.js fixed hot handling 2014-08-14 11:12:19 +02:00
addStyles.js SourceMap support 2014-11-03 23:23:50 +01:00
index.js Allow undefined option 2014-10-21 11:47:15 +02:00
package.json 0.8.2 2014-11-03 23:24:16 +01:00
url.js fixed hot handling 2014-08-14 11:12:19 +02:00
useable.js Fix useable api 2014-09-29 17:43:33 -04:00

README.md

style loader for webpack

Usage

Documentation: Using loaders

Simple API

require("style!raw!./file.css");
// => add rules in file.css to document

It's recommended to combine it with the css-loader: require("style!css!./file.css").

It also possible to add a URL instead of a css string:

require("style/url!file!./file.css");
// => add a <link rel="stylesheet"> to file.css to document

Reference-counted API

var style = require("style/useable!css!./file.css");
style.use(); // = style.ref();
style.unuse(); // = style.unref();

Styles are not added on require, but instead on call to use/ref. Styles are removed from page if unuse/unref is called exactly as often as use/ref.

Note: Behavior is undefined when unuse/unref is called more often than use/ref. Don't do that.

Options

singleton

If defined, the style-loader will re-use a single <style> element, instead of adding/removing individual elements for each required module. Note: this option is on by default in IE9, which has strict limitations on the # of style tags allowed on a page. You can enable or disable it with the singleton query parameter (?singleton or ?-singleton).

By convention the reference-counted API should be bound to .useable.css and the simple API to .css (similar to other file types, i. e. .useable.less and .less).

So the recommended configuration for webpack is:

{
  module: {
    loaders: [
      { test: /\.css$/, exclude: /\.useable\.css$/, loader: "style!css" },
      { test: /\.useable\.css$/, loader: "style/useable!css" }
    ]
  }
}

License

MIT (http://www.opensource.org/licenses/mit-license.php)