node package manager
Stop writing boring code. Discover, share, and reuse within your team. Create a free org »


Build Status

Render batches of Stylus files. This module expects stylus to be available via require('stylus') where it is run. This is so that you can use whatever version of stylus you want to.

It provides a default compile function which can be customised by passing in stylus options. Otherwise, a completely custom compile function can be passed in.

To use Nib or Autoprefixer Stylus, pass a custom use function.

The render function returns an event emitter so you can listen for log events.


npm install stylus-renderer


var render = require('stylus-renderer')

render(stylesheets, options, cb)

  • stylesheets an array of stylesheets to render
  • options is an options hash
    • src the source directory, defaults to PWD
    • dest the destination directory, defaults to PWD
    • use an optional plugin, such as Nib. Also accepts an array of plugins
    • define pass JavaScript-defined functions or global variables to stylus as an array of objects
    • stylusOptions hash of options to pass though to stylus
    • compile a custom compile function. If compile is set, stylusOptions will have no effect.
  • cb is the callback function (err) {} (err is null if ok)


render(['index.styl'], { use: nib(), stylusOptions: { compress: 'true' } }, function (err) {
  if (err) throw err
}).on('log', function (msg, level) {
  console.log(level + '' + msg)


Licensed under the New BSD License