B
B
BigKompot2016-07-07 00:05:20
gulp.js
BigKompot, 2016-07-07 00:05:20

Why does gulp execute a task but not end the process?

A running gulp.task executes correctly, but the process does not exit.
Delivered gulp 4.0.0-alpha.2 and processes ceased to be completed.
What to do?
Just in case my gulpfile.js

'use strict';

var gulp = require('gulp');
var less = require('gulp-less');
var debug = require('gulp-debug');
var sourcemaps = require('gulp-sourcemaps');
var gulpIf = require('gulp-if');
var clean = require('gulp-clean');
var exit = require('gulp-exit');
var watch = require('gulp-watch');

var isDevelopment = !process.env.NODE_ENV || process.env.NODE_ENV == 'development';

gulp.task('less', function() {
  return gulp.src('src/style.less')
    .pipe(gulpIf(isDevelopment, sourcemaps.init()))
    // .pipe(debug({title: 'src'}))
    .pipe(less())
    // .pipe(debug({title: 'less'}))
    .pipe(gulpIf(isDevelopment, sourcemaps.write()))
    .pipe(gulp.dest('build'));
});


gulp.task('clean', function() {
  return gulp.src('build', {read: false})
    .pipe(clean());
});

gulp.task('build', gulp.series(
  'clean', 'less'));

gulp.watch('src/**/*.less', gulp.series('less'));

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2016-07-07
@BigKompot

So after all, you run watch at the end - so it monitors changes in files, and for this the script, of course, must be launched. Most likely, you just forgot to wrap watch in a separate task and call it only when needed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question