The fork of cssobjectify by Andrey Popp. Source transform for browserify or dcompose which converts LESS into JSON objects which can be used further by libraries like React to assign styles to UI components.
styles.less
:
.block {
font-size: 12px;
background-color: red;
&__element {
&--modifier {
background-color: blue;
}
}
}
myapp.js
:
var React = require('react-tools/build/modules/React');
var Styles = require('./styles.less');
var MyComponent = React.createClass({
render: function() {
return (
<div style={Styles['.block__element--modifier']}>
Hello, world!
</div>
)
}
});
Use npm to install the package:
% npm install lessobjectify
And use it with browserify:
% browserify -t lessobjectify ./myapp.js
where ./myapp.js
or its dependencies can reference *.css
files by
require(...)
calls.