You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ModCSS is a Node.js require extension, Browserify|DCompose transform & Webpack loader that
converts CSS or Stylus into JSON. This can be used further by libraries like
React to assign styles to UI components.
The main use case (as of this writing) is to write your styles using expressive Stylus syntax and isolate them to a single component, usually by assigning JSON to a React component.
where ./my-component.js or its dependencies can reference *.css or *.styl files by
require(...) calls.
Or programmatically with browserify (for instance, via gulp):
var browserify = require('browserify');
var modcss = require('modcss');
// in your task
var b = browserify(config);
b.transform(modcss, { paths: [ somePathHere ] });
Node.js
require('modcss').register(/* stylusPaths, useNib */)
const myComponentStylesAsJSON = require('../styl/components.styl')
// Use require('modcss').deregister() to remove the association with CSS & Stylus files
ModCSS is based on the abandoned project cssobjectify. Issues went unanswered, the tests didn't pass, etc. I've also added Stylus support to this module, whether used from Node.js or Browserify.
About
A Node.js require extension and Browserify transform to turn CSS or Stylus into JSON for React components