Search code examples
javascriptservergulpgulp-watch

Make gulp run on my server non-stop


Is there any solution I can make gulp working on my server without me needing to connect with SSH and the writing gulp js:watch sass:watch ? This is my current gulpconfig.js

var gulp = require('gulp');
var sass = require('gulp-sass');
var sassGlob = require('gulp-sass-glob');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');

gulp.task('js:build', function() {
  gulp.src('js/*.js')
    .pipe(concat('functions.js'))
    .pipe(uglify())
    .pipe(gulp.dest('./js/'))
});

gulp.task('js:watch', function() {
    gulp.watch('js/*.js', ['js:build'])
});

gulp.task('sass:build', function () {
    return gulp
        .src('css/global.scss')
        .pipe(sassGlob())
        .pipe(sass())
        .pipe(gulp.dest('css'));
});

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

Solution

  • The screen program for linux is exactly what you are looking for:

    • Install screen
    • Open a new screen session: screen -dR
    • Start gulp
    • Disconnect from your screen session: CTRL-A, d

    Run a command in a shell and keep running the command when you close the session