style loader module for webpack
npm install simple-universal-style-loader tag
javascript
require("simple-universal-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's also possible to add a URL instead of a CSS string:
` javascript
require("simple-universal-style/url!file!./file.css");
// => add a to file.css to document
`
$3
(experimental)
When using local scope CSS the module exports the generated identifiers:
` javascript
var style = require("simple-universal-style!css!./file.css");
style.placeholder1 === "z849f98ca812bc0d099a43e0f90184"
`
$3
` javascript
var style = require("simple-universal-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.
$3
On server side we can't load styles into the DOM but to collect them and use when assembling the layout.
Example with React:
` javascript
React Redux Starter Kit
{ global.__styles__.map(style =>
type="text/css">{style.parts.map(part => part.css + "\n")})
}
`
From version 0.14.4 the captured styles can be get by using getStyles() as well:
` javascript
import { getStyles } from 'simple-universal-style-loader'
`
$3
#### insertAt
By default, the style-loader appends