E
E
Elena2020-07-14 12:45:20
gulp.js
Elena, 2020-07-14 12:45:20

Why doesn't Gulp watch update files automatically?

I set the gulp watch command - everything is worked out. And it doesn't follow automatically. That is, when changing any file, gulp watch is silent and I need to issue a command again and again to update.

Autosave in the editor is worth it.
How can I make gulp automatically update files when files change?
//gulpfile.js

'use strict'

var gulp = require('gulp');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
sass.compiler = require('node-sass');

gulp.task('styles', function (done) {
return gulp.src('src/css/*.scss')
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.
.pipe(autoprefixer())
.pipe(gulp.dest('build/css/'));
done();
});

gulp.task('css', function (done) {
gulp.src('src/css/**/*.css')
.pipe(gulp.dest('build/css/'));
done();
});

gulp.task('views', function (done) {
gulp.src('src/*.html')
.pipe(gulp.dest('build/'));
done();
});

gulp.task('img', function (done) {
gulp.src('src/img/**/*.*')
.pipe(gulp.dest('build/img/'));
done();
});

gulp.task('scripts', function (done) {
gulp.src('src/js/*.
done();
});

gulp.task('build', gulp.parallel('styles', 'css', 'views', 'img', 'scripts'), function (done) {
done();
});

gulp.task('watch', gulp.parallel('build'), function (done) {
gulp.watch('src/css/*.scss', gulp.parallel('styles'));
gulp.watch( 'src/css/**/*.css', gulp.parallel('css'));
gulp.watch('src/*.html', gulp.parallel('views'));
gulp.watch(' src/img/*.*', gulp.parallel('img'));
gulp.watch('src/js/*.js', gulp.parallel('scripts'));
done();
});

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question