I'm using webpack, I have installed both style-loader
and css-loader
styles.css
body {
font-family: Arial;
color: white;
}
.foo {
color:blue;
}
.bar {
color:red;
}
entry.js
require('!style!css!./styles.css');
var css = require('!css!./styles.css');
console.log(css);
Using require('!style!css!./styles.css')
results <style>
into the page as below
Using var css = require('!css!./styles.css')
then console.log(css)
results as below
Question
Is it possible to load only specific css class e.g. var fooClass = css.foo
, I intend to use this with my React components, e.g. <input style={ foo }/>
or maybe <input className={ foo }/>