gruntjs/grunt-contrib-stylus

Unexpected passed variables value through define

robhrt7 opened this issue · 7 comments

I'me defining global variables through define:

define: {
  test: '1px',
  $color: 'red'
}

And from this input.styl

.test {
    font-size: test;
    color: $color;
    }

I get wrong, quoted properties:

.test {
  font-size: '1px';
  color: 'red';
}

Here's an expected output:

.test {
  font-size: 1px;
  color: red;
}

Same result with lighter Stylus syntax without braces and semicolons.

You need to use unquote function:

font-size: unquote(test);

(Also duplicate of #44.)

Does we need to do the same with native Stylys .define?

I need to pass vendors variable, without defining it in unquoted way somewhere in stylus.

Any ideas how to pass vendors variable to configure Stylus?

It seems impossible because Stylus defines external variables before executing any code but vendors is an just ordinary variable in lib/functions/index.styl so it overwrites value passed to define.

The only (I think) way is to define variable with a different name:

define: {
    vendors_: ['such', 'prefixes']
}
vendors = vendors_

Okay, thanks for your ideas. I'll probably just use imported file with configs.