0

I am having some issues with the random() function in sass when compiling on my ubuntu server.

Currently it is working fine locally however if I run the gulp tasks on my ubuntu box gulp-sass the output is only generated once.

This is the sass:

@function multipleBoxShadow($stars, $opacity) {
  $value: '#{random(2000)}px #{random(2000)}px rgba(255, 255, 255, #{$opacity})';
  @for $i from 2 through $stars {
    $value: '#{$value} , #{random(2000)}px #{random(2000)}px rgba(255, 255, 255, #{$opacity})'
  }
  @return unquote($value)
}

@mixin starBase($speed, $size, $amount, $opacity) {
  box-shadow: multipleBoxShadow($amount, $opacity);
  animation: animStar $speed linear infinite;
}

#stars {
  @include starBase(50s, 1px, 700, 1);
}

And this is the output on the ubuntu box when using gulp-sass:

#stars {
  animation: animStar 100s linear infinite;
  box-shadow: 321px 321px rgba(255, 255, 255, 1) , 321px 321px rgba(255, 255, 255, 1) , 321px 321px rgba(255, 255, 255, 1) etc etc....
}

As you can see its only generating a random number once and using that same value for all repetitions unlike on my local machine where the output is random each time.

If I then try to use the sass compiler outside of grunt sass sass/default.css style/default.css then random() fails completly:

#stars {
  animation: animStar 100s linear infinite;
  box-shadow: random(2000)px random(2000)px rgba(255, 255, 255, 1) , random(2000)px random(2000)px rgba(255, 255, 255, 1) etc etc....
}

Is there something I need to install on my ubuntu box for random() to compile correctly? I always assumed it came native with sass.

Here is a SassMeister to demo correct compiling: http://sassmeister.com/gist/165fe1dcc831220c8717

Simon Staton
  • 4,345
  • 4
  • 27
  • 49

1 Answers1

0

Turns out I just had the wrong version of sass installed on my server, probably should of checked that first. It now works using the sass compiler, sass-gulp still only generates random() once however

Simon Staton
  • 4,345
  • 4
  • 27
  • 49