Answer the question
In order to leave comments, you need to log in
Why is watch not working in gulp?
Hello everyone, I'm setting up gulp, please tell me where the error is.?
const {src, dest} = require("gulp");
const scss = require('gulp-sass') (require('sass'));
const concat = require('gulp-concat');
const watch = require('gulp-watch');
function styles() {
return src('./src/scss/style.scss')
.pipe(scss({outputStyle: 'compressed'}))
.pipe(concat('style.min.css'))
.pipe (dest('./dist/css'))
}
function watching() {
watch(['./src/scss/**/*.scss'], styles)
}
exports. styles = styles;
exports.watching = watching;
When you run (gulp watching), the inscription appears in the console that it is watching, but it does not transfer changes from the scss file to the min.css file. When I write (gulp styles), everything is transferred, but accordingly there is no tracking.
Answer the question
In order to leave comments, you need to log in
I noticed that you are missing a piece here.
I think that's about it.
const { src, dest, series, watch } = require('gulp');
const scss = require('gulp-sass') (require ('sass'));
const concat = require('gulp-concat');
const build = ('build/'); // Папка готовой сборки.
function styles() {
return src('./src/scss/style.scss')
.pipe(scss({outputStyle: 'compressed'}))
.pipe(concat('style.min.css'))
.pipe(dest('./dist/css'))
}
function clear() { // Чистит папку билд.
return del(build)
}
function stream() {
watch(['./src/scss/**/*.scss'], series(styles))
}
exports.build = series(clear, styles, stream) // Запускаем по очереди задачи.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question