0

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.

Image: One file change

The plugins I'm using

  • gulp-load-plugins to load the plugins
  • gulp-watch to watch for file changes
  • gulp-notify to notify stylus has been compiled
  • gulp-stylus to compile stylus
  • gulp-exec to run compile task even when a partial was edited
  • gulp-autoprefixer to prefix css
  • gulp-plumber so gulp-watch doesn't die on error
JordyvD
  • 1,565
  • 1
  • 18
  • 45
  • you dont have `return` statement like `return gulp.src(`, that means gulp wont know when the task is finished, which might be causing this issue – harishr Mar 17 '16 at 12:18
  • Is Dropbox or similar thing open while working? – atilkan Apr 05 '16 at 18:08

0 Answers0