gruntjs / grunt-contrib-stylus

Compile Stylus files to CSS.
http://gruntjs.com/
MIT License
174 stars 70 forks source link

Relative destination #138

Closed cakeinpanic closed 9 years ago

cakeinpanic commented 9 years ago

Hello! I've had this problem with stylus url resolving: https://github.com/stylus/stylus/issues/1933 And figured out your plugin processes all css files to one folder specified in dest. But when my src is like src/component/*/in.styl and i want to generate each .css at src/component/*/css/out.css, i should use rename to move my files. So I made an improvement – now param relativeDest can be passed and then all .css files will be generated relatively to dest. For example

  task: {
        files: [{
          expand: true,
          relativeDest: '/out',
          src: ['test/in.styl'],
          dest: 'tmp',
          ext: '.css'
        },

will generate tmp/test/out/in.css and, the most important, will provide this path to stylus to let it resolve urls correctly

cakeinpanic commented 9 years ago

hello, is anyone here?

cakeinpanic commented 9 years ago

@tkellen @shama @ctalkington @vladikoff, patiently waiting for your review)

shama commented 9 years ago

Thank you for the PR! I think this use case is already sufficiently handled by rename though. Unless there is a use case I'm missing here?

Also we reserve configuration at that scope to Grunt supplied options. Any additional configuration for a plugin should be specified in opitons instead.

cakeinpanic commented 9 years ago

rename option can't help because it generates .css file near .styl and THEN moves it to another folder, and all resources paths are resolved relatively to it's first location. So when file is moved, all resources paths point to not existing files.

Talking about position of relativeDest param – I get your point, this will be changed.

cakeinpanic commented 9 years ago

So what would you say now, @shama?

shama commented 9 years ago

Added some notes. Could you also add this option to the docs: https://github.com/gruntjs/grunt-contrib-stylus/blob/master/docs/stylus-options.md? Thanks!

cakeinpanic commented 9 years ago

@shama, check now please, is everythink ok?

cakeinpanic commented 9 years ago

I also noticed that grunt-contrib-stylus doesn't resolve urls from imported .css files (option "include css") This happens because of https://github.com/stylus/stylus/issues/1957

It can be fixed by additional .set() or updating stylus to 0.52.0, so I've done this within this issue

shama commented 9 years ago

Thanks a bunch for this @cakeinpanic! :sparkles: :+1: :sparkles:

I'm going to do some other maintenance and then publish a new release.