Q:

Stylus - set url() prefix for cli compiles

I'm using Stylus CSS preprocessor, console compiler not javascript middleware. I'm looking for some kind of path prefix configuration.
So when I write (in foo.styl):
#lolipop
  background: url(images/lolipop.png)

and set prefix static/, I want it to compile into:
#lolipop {
    background: url("static/images/lolipop.png");
}

Is this possible with stylus's console compiler only?

A:

Edit: Since you use the stylus executable, here is your solution. It seems totally undocumented, but you can actually --use url and pass along the options as a string, like this:
stylus --use url --with "{ paths: [ './static' ] }"

This feature works similar to url from the stylus url() documentation and takes the same options:

For example if our images live in ./public/images and we wish to use url(images/tobi.png), we can pass paths with our public directory, which will become part of the lookup process. Like-wise if we wanted url(tobi.png) instead, we would pass paths: [__dirname + '/public/images'].

stylus(str)
  .set('filename', __dirname + '/css/test.styl')
  .define('url', stylus.url({ paths: [__dirname + '/public'] }))
  .render(function(err, css){

});

