0.6.0 • Published 7 years ago

styletron-loader v0.6.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

styletron-loader

Webpack loader to load CSS into a styletron compatible CSS object by specifying a string with CSS selectors.

Very much inspired by:

Install

npm install -D styletron-loader

or

yarn add --dev styletron-loader

Usage

Documentation: Using loaders Create an entry to load .css files in your webpack.config:

module: {
  loaders: [{
      test: /\.css$/,
      loaders: [ 'styletron-loader' ],
      exclude: /node_modules/
    }
  ]
}

Requiring CSS rules:

.button {
  font-size: 1.5em;
  color: fuchsia;
}
.button:hover,
.button:focus {
  color: crimson;
}
@media screen and (max-width: 768px) {
  .button {
    font-size: 2em;
  }
}
.red-bg {
  background-color: red
}
var util = require('styletron-loader/util');
var parsedCSS = require('./styles.css');

parsedCSS['.button']
/*
{ 'font-size': '1.5em',
  color: 'fuchsia',
  ':hover': { color: 'crimson' },
  ':focus': { color: 'crimson' },
  '@media screen and (max-width: 768px)': { 'font-size': '2em' }
}
*/

var styles = util(parsedCSS);

styles('.button .red-bg');
/*
{ 'font-size': '1.5em',
  color: 'fuchsia',
  ':hover': { color: 'crimson' },
  ':focus': { color: 'crimson' },
  '@media screen and (max-width: 768px)': { 'font-size': '2em' },
  'background-color': 'red'
}
*/
0.6.0

7 years ago

0.5.6

7 years ago

0.5.5

7 years ago

0.5.4

7 years ago

0.5.3

7 years ago

0.5.2

7 years ago

0.5.1

7 years ago

0.5.0

7 years ago

0.3.3

7 years ago

0.3.2

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago