0

I'm using Gulp as my task runner, and gulp-ruby-sass to compile my sass files into css.

The error I'm getting on my gulp default task:

enter image description here

My default Gulp task:

gulp.task('default', ['delete', 'web_css', 'dash_css', 'web_js', 'dash_js']);

My 2 compile SASS tasks:

// Compile public SASS
gulp.task('web_css', function() {
    return sass('client/website/_sources/sass/bitage_web.scss', { style: 'compressed' })
        .pipe(sourcemaps.init())
        .pipe(sourcemaps.write('./maps'))
        .pipe(gulp.dest('client/website/assets/css'));
});

// Compile dashboard SASS
gulp.task('dash_css', function() {
    return sass('client/dashboard/_sources/sass/bitage_app.scss', { style: 'compressed' })
        .pipe(sourcemaps.init())
        .pipe(sourcemaps.write('./maps'))
        .pipe(gulp.dest('client/dashboard/assets/css'));
});

Both tasks above are virtually identically.

When I run the default task (gulp):

  1. The website css compiles ok
  2. All the js compiles ok
  3. But then I get that error before the dash_css finishes, and the css is not compiled :(

enter image description here

Additional notes:

  • If make a change in gulp watch the dash_css will compile just fine.
  • If I run just gulp dash_css it also compiles just fine.
  • I only have this Errno::ENOENT bug when I run the default task.

enter image description here

Do you see anything strange above? Or have run into this issue before?

Leon Gaban
  • 36,509
  • 115
  • 332
  • 529
  • 1
    Try disabling `delete` task. If that prevents the error include it in the question. – Heikki Feb 24 '15 at 01:40
  • @Heikki hey you are on to something, removing the `delete` didn't work, but I rearranged things and made `dash_css` the first task and there wasn't any error! Only now it's putting stuff in the wrong folders.. double checking – Leon Gaban Feb 24 '15 at 01:50
  • Ok so with delete removed and dash_css made the first function, it's putting both compiled css files into the website > assets > css directory. Now I'm thinking I need some pipes in my default task to watch the order of things perhaps – Leon Gaban Feb 24 '15 at 01:52
  • 1
    http://stackoverflow.com/questions/28144068/sequencing-tasks-with-gulp/28147701 – Heikki Feb 24 '15 at 01:53

2 Answers2

1

Use callback so that gulp knows when the task is complete:

gulp.task('delete', function(cb) {
    del([
        'client/website/assets/css/maps',
        'client/website/assets/css/bitage_web.css',
        'client/dashboard/assets/css/maps',
        'client/dashboard/assets/css/bitage_app.css',
        'client/website/assets/js/*',
        'client/dashboard/assets/js/*'
    ], cb);
});

Make delete run before other tasks for example with run-sequence.

Heikki
  • 15,329
  • 2
  • 54
  • 49
  • Thanks! I think `run-sequence` is the key, right now both css files are getting compiled into both dash and web directories... but at least no more error :) – Leon Gaban Feb 24 '15 at 02:05
-1

I've changed

gulp.task('web_css', function() {
    return sass(....

to:

gulp.task('web_css', function() {
    return gulp.src('
Liam
  • 27,717
  • 28
  • 128
  • 190