Answer the question
In order to leave comments, you need to log in
gulp error. Compiling sass to css. Where is the mistake?
const gulp = require('gulp'),
sass = require('gulp-sass'),
cssmin = require('gulp-cssmin'),
rename = require('gulp-rename'),
plumber = require('gulp-plumber'),
watch = require('gulp-watch');
gulp.task('sass', function () {
//указываем за какой папкой следить
return gulp.src('./sass/**/*.sass')
.pipe(plumber())
//указываем куда сохранять CSS
.pipe(gulp.dest('./css'));
});
gulp.task('cssmin', function () {
//указываем где лежит CSS
gulp.src('./css/*.css')
.pipe(plumber())
.pipe(cssmin())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('dist'));
});
gulp.task('watch', function(){
gulp.watch('./sass/**/*.sass', ['sass']);
gulp.watch('./css/**/*.css', ['cssmin']);
});
gulp.task('default', ['watch']);
Answer the question
In order to leave comments, you need to log in
I think the problem is in the watch function. depending on what version of gallp you have.
my watch function is written like this
gulp.task('watch', function() {
gulp.watch('src/sass/*.scss', gulp.series('sass'));
});
Most likely it's a version issue, here, it seems, this problem was sorted out:
Gulp does not work, gives an error?
Try like this:
const gulp = require('gulp'),
sass = require('gulp-sass'),
cssmin = require('gulp-cssmin'),
rename = require('gulp-rename'),
plumber = require('gulp-plumber'),
watch = require('gulp-watch');
gulp.task('sass', function(done) {
gulp.src("./sass/**/*.sass")
.pipe(plumber())
.pipe(sass())
.pipe(gulp.dest("./css"))
.pipe(browserSync.stream());
done();
});
gulp.task('cssmin', function () {
//указываем где лежит CSS
gulp.src('./css/*.css')
.pipe(plumber())
.pipe(cssmin())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('dist'));
});
gulp.task('watch', function(){
gulp.watch('./sass/**/*.sass', gulp.series('sass'));
gulp.watch('./css/**/*.css', gulp.series('cssmin'));
});
gulp.task('default', gulp.series('sass', 'cssmin', 'watch'));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question