I'm using Gulp to compile stylus, but the task seems to run twice making gulp-notify
trip.
Here's my gulpfile.js
var gulp, plugins;
gulp = require('gulp');
plugins = require('gulp-load-plugins')();
/**
* Watch for changes on stylus files, when detecting change run stylus task
* @return {void}
*/
gulp.task('watch-stylus', function() {
gulp.src('./app/Resources/stylus/**/*.styl')
.pipe(plugins.plumber())
.pipe(plugins.watch('./app/Resources/stylus/**/*.styl', {
verbose: true,
readDelay: 0
}))
.pipe(plugins.exec('gulp stylus'))
.pipe(plugins.notify("Stylus compiled"))
.pipe(plugins.plumber.stop());
});
/**
* Compile stylus and auto prefix the compiled css
* @return {void}
*/
gulp.task('stylus', function() {
gulp.src(['./app/Resources/stylus/**/*.styl', '!./app/Resources/stylus/**/_*.styl'])
.pipe(plugins.plumber())
.pipe(plugins.stylus())
.pipe(plugins.autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(plugins.plumber.stop())
.pipe(gulp.dest('web/css'));
});
Things I've checked
- No multiple dests.
- Input and output dir are different.
The plugins I'm using
gulp-load-plugins
to load the pluginsgulp-watch
to watch for file changesgulp-notify
to notify stylus has been compiledgulp-stylus
to compile stylusgulp-exec
to run compile task even when a partial was editedgulp-autoprefixer
to prefix cssgulp-plumber
sogulp-watch
doesn't die on error