xylar xylar - 3 months ago 42
Sass (Sass) Question

Gulp.js starts sass task but doesn't finish

My gulpfile.js

var gulp = require('gulp');

// plugins
var sass = require('gulp-sass');
var minifycss = require('gulp-minify-css');

// compile sass
gulp.task('sass', function() {
return gulp.src('static/css/scss/main.scss')
.pipe(sass())
.pipe(minifycss())
.pipe(gulp.dest('/static/css/main.css'));
});

gulp.task('watch', function() {
gulp.watch('static/css/scss/*.scss', ['sass']);
})

gulp.task('default', ['watch']);


When I run
gulp
I get the following output:

[gulp] Using gulpfile /var/www/example/gulpfile.js
[gulp] Starting 'watch'...
[gulp] Finished 'watch' after 21 ms
[gulp] Starting 'default'...
[gulp] Finished 'default' after 23 μs


Then when I save my
main.scss
file it outputs:

[gulp] Starting 'sass'...


At which point it just hangs and never finishes. What am I doing wrong?

Answer

The return inside the sass task seemed to break it, updated my gulpfile.js to following to get it working:

var gulp = require('gulp');

// plugins
var sass = require('gulp-sass');
var minifycss = require('gulp-minify-css');

// compile sass
gulp.task('sass', function() {
    gulp.src('static/css/scss/main.scss')
        .pipe(sass())
        .pipe(minifycss())
        .pipe(gulp.dest('/static/css'));
});

gulp.task('watch', function() {
    gulp.watch('static/css/scss/*.scss', ['sass']);
})

gulp.task('default', ['watch']);