gulp-stylus-vars

Inject variables in stylus files

Usage no npm install needed!

<script type="module">
  import gulpStylusVars from 'https://cdn.skypack.dev/gulp-stylus-vars';
</script>

README

gulp-stylus-vars

Inject variables in stylus files from a js object.

Usage

npm install gulp-stylus-vars

var stylusVars = require('gulp-stylus-vars');

gulp.task('stylus', function() {
  var variables = {
    stringTest: "hello",
    string2Test: "https://github.com/giowe/gulp-stylus-vars",
    integerTest: 123,
  };

  return gulp.src([
    'src/styles/main.styl'
  ])
    .pipe(stylusVars(variables, { verbose: true }))
    .pipe(stylus())
    .pipe(gulp.dest('dist'))
});

This script will prepend the following code to your main.styl file:

stringTest = hello
string2Test = "https://github.com/giowe/gulp-stylus-vars"
integerTest = 123

So you can use all those variables inside your stylus file. Quotes will be added when needed via regex.