Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gulp watch sass causes terminal to hang - is that the point?

Tags:

terminal

gulp

So I just got my hands dirty with Gulp. I have never worked with Grunt, but it seems that Gulp is the new big thing. Everything seems to work fine. I have successfully compiled SCSS into CSS with the following gulpfile.js:

// Include gulp
var gulp = require('gulp'); 

// Include Our Plugins
var sass = require('gulp-sass');
var rename = require('gulp-rename');


// Compile Our Sass
gulp.task('sass', function() {
    return gulp.src('./scss/*.scss')
        .pipe(sass())
        .pipe(gulp.dest('./css'));
});

// Rerun the task when a file changes
gulp.task('watch', function () {
  gulp.watch('scss/**/*.scss', ['sass']);
});

// Default Task
gulp.task('default', ['sass', 'watch']);

Thing is: When I run Gulp default in the terminal it starts the script, but never ends it. I'm assuming this is the point, that in order for Gulp to watch my files - it has to keep running.

It's on standby with this:

[gulp] Running 'sass'...
[gulp] Finished 'sass' in 8.47 ms

If that's the case - how do I stop it from running without closing and reopening the Terminal? I'm sorry if this is simple but i have no clue when it comes to the Terminal.

like image 797
Malibur Avatar asked Jan 11 '23 08:01

Malibur


1 Answers

gulp watch is designed to watch the file changes, it acts as a running process.

The README shows an example of its usage: gulp-watch

The command: Ctrl+C will stop the process.

Once started modifying any file in the watch directive will trigger the action in the reload. You currently do not have any action for your watch, this will trigger a action when the sass files change:

gulp.watch('./scss/**/*.scss', ['sass']);
like image 105
SteveLacy Avatar answered Jan 30 '23 01:01

SteveLacy