Answer the question
In order to leave comments, you need to log in
Correct transition of Gulp from version 3 to version 4?
Automatically updated from version 3 to version 4 and, accordingly, tasks stopped running. Can you help rewrite the following three tasks to the new syntax for an example?
gulp.task('default', ['watch']);
gulp.task('watch', function () {
gulp.watch('src/img/*', ['compress']);
});
gulp.task('css', function () {
return gulp.src('src/scss/*.scss')
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(sass())
.on('error', sass.logError)
.pipe(cleanCSS())
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist/css'))
.pipe(browserSync.stream());
});
Answer the question
In order to leave comments, you need to log in
const gulp = require('gulp');
function compress() {
// compress task
}
function watch() {
gulp.watch('src/img/*', compress);
}
function css() {
return gulp
.src('src/scss/*.scss')
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(sass())
.on('error', sass.logError)
.pipe(cleanCSS())
.pipe(
autoprefixer({
browsers: ['last 2 versions'],
cascade: false
})
)
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist/css'))
.pipe(browserSync.stream());
}
module.exports.default = gulp.series(watch); // ну если один таск можно и просто `watch`.
module.exports.watch = watch;
module.exports.css = css;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question