stylus-lemonade
stylus-lemonade copied to clipboard
Relative path issues
I'm running stylus from the root of my project (let's call it /
, on a stylus file in a /css
subdirectory.
That stylus file wants to make a sprite in /img
, and the CSS output will also be in the /css
directory.
For the browser to have a nice relative path from the CSS to the images, the CSS output needs to have url(../img/whatever.png)
, since the CSS is in /css
and the images are in /img
.
But when stylus-lemonade is putting together my sprite, it writes relative to where stylus is run from. In my stylus if I use sprite-map('img/whatever')
the sprite is written to the right place but sprite-url
gives ./img/whatever.png
, which is no good for the browser. If I use sprite-map('../img/whatever')
instead, it attempts to write the sprite to a sibling directory of my project root called img
, which does not exist. In fact it silently exits with no error and the file is not written at all if that directory doesn't exist.
Is this a bug or am I missing some way around this?
I've figured it out -- I needed to give the options.
In case anyone else comes here, if using the stylus binary you need to use the undocumented --with
option:
stylus --use node_modules/stylus-lemonade --with '{"image_path": "assets/", "sprite_path": "img/", "sprite_url": "../img/"}' ...
Perhaps some documentation on this would be good. Close at will.