0.6.0 • Published 7 years ago

cssobjects-loader v0.6.0

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

cssobjects-loader

load StyleSheets as JS-Objects

Build Status npm version devDependencies Status Known Vulnerabilities Maintenance PRs Welcome

v0.5.0 released

stable version with webpack 4 compatibility

what is it?

  • webpack loader
  • per nativeCss
  • transforms css-properties to camelCase
  • very handy for react style injections

how to use it?

npm install cssobjects-loader --save-dev

your.so

.test
	font-size 20px
#anotherTest
	padding-top 5px
.test23
	font-size 23px
    .testInner
        font-decoration none

your.js

let style 	= require('cssobjects-loader!stylus-loader!./your.so');

console.log(style);
// {
// 	test: {
// 		'fontSize': '20px'
// 	},
// 	anotherTest: {
// 		'paddingTop': '5px'
// 	},
// 	test23: {
// 		'fontSize': '23px'
//      testInner: { // atm: only 1 lvl deep
//          'fontDecoration': 'none'
//      }
// 	}
// }

what else to know?

to keep the style properties as they are, pass the query 'transform=false' to the loader

let style = require('cssobjects-loader?transform=false!stylus-loader!./your.so');

for pure css just use

let style = require('cssobjects-loader!./your.css');

for other style preprocessor syntax (less, sass, scss, ...) just add the realated loader (the loader has to output css!)

let style = require('cssobjects-loader!sass-loader!./your.sass');

for ES6/7 usage, define loaders in the webpack config

{
    test: /\.(so)$/, // .so = custom file extension
    loader: 'cssobjects-loader?transform=true!stylus-loader'
}
// so you can just
// import yourStyleObject from '/styles/your.so'

issues

  • for objectformat and enhanced usage go to nativeCss
  • loader related issues or PR's are welcome
  • known issues:
    • native-css not found (issue #18)

v1 roadmap

  • inject style's subclasses recursively
  • use humps for objectKeys
  • write testscripts, DocBlocks, Comments
  • ES6 (/dist + buildScript)
0.6.0

7 years ago

0.5.1

7 years ago

0.5.0

7 years ago

0.4.1

9 years ago

0.4.0

9 years ago

0.3.9

9 years ago

0.3.8

9 years ago

0.3.7

9 years ago

0.3.6

9 years ago

0.3.5

9 years ago

0.3.3

9 years ago

0.3.2

9 years ago

0.3.1

9 years ago

0.3.0

9 years ago

0.2.9

10 years ago

0.2.8

10 years ago

0.2.7

10 years ago

0.2.6

10 years ago

0.2.5

10 years ago

0.2.4

10 years ago

0.2.3

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.9

10 years ago

0.1.8

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago