Skip to content

Instantly share code, notes, and snippets.

@mlms13
Last active December 3, 2015 21:31
Show Gist options
  • Save mlms13/6a1c61e8a8cdf4d025f1 to your computer and use it in GitHub Desktop.
Save mlms13/6a1c61e8a8cdf4d025f1 to your computer and use it in GitHub Desktop.
Conditionally switch between source maps and minification based on a gulp flag.
// `gulp stylus --prod` will enable "production mode"
// `gulp stylus` will leave the prod flag undefined, so it will do a dev build
var gulp = require('gulp'),
gutil = require('gulp-util'),
prod = gulp.env.prod;
gulp.task('stylus', ['cleancss'], function () {
var stylus = require('gulp-stylus'),
prefix = require('gulp-autoprefixer'),
minify = require('gulp-minify-css');
return gulp.src('./styl/main.styl')
.pipe(stylus({linenos: !prod}))
.pipe(prod ? prefix() : gutil.noop())
.pipe(prod ? minify() : gutil.noop())
.pipe(gulp.dest('./dist/css'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment