Home javascript How to transfer your project on Gulp 4

How to transfer your project on Gulp 4

Author

Date

Category

In general, after seeing video tutorials by Node.js, I decided to do something my own. But the problem is that I have Gulp 4, and the code from gulpfile.js is written on the 3rd.

Question: how to fit it under version 4?

var gulp = require ('gulp'),
  Sass = Require ('Gulp-Sass');
Gulp.Task ('Sass', Function () {
  Return Gulp.Src ('[/ Public / Sass / ** / *. Sass', '/Public/sass/**/*Scss]')
       .pipe (sass ({OutputStyle: 'Expanded'}). On ('error', sass.logerror)) // Transform Sass in CSS by Gulp-Sass
       .pipe (gulp.dest ('Public / Css'));
});
Gulp.Task ('Watch', Function () {
 gulp.watch (['Public / Sass / ** / *. Sass', 'Public / Sass / ** / *. SCSS'], ['sass']);
});
gulp.task ('Default', ['Watch']);

Answer 1

redid your config under Gulp 4 format, according to comments, it should be clear.

"use strict";
/ **
 * Gulpfile for Gulp 4
 * /
const {SRC, Dest, Watch, Series, Parallel} = Require ('Gulp');
Const sass = Require ('Gulp-Sass');
// Features for tasks
Function Sasstask () {
  Return SRC ('[/ Public / Sass / ** / *. sass', '/public/sass/**/*.scss]')
    .pipe (Sass ({OutputStyle: 'Expanded'}). On ('Error', Sass.logerror))
    .pipe (Dest ('Public / CSS'));
}
FUNCTION WATCHTASK () {
  Watch (['Public / Sass / ** / *. Sass', 'Public / Sass / ** / *. SCSS'], Parallel (Sasstask));
}
// Tasks
Exports.sass = Series (
  Sasstask.
);
Exports.watch = Series (
  Watchtask.
);
exports.default = Series (
  Watchtask.
);
Previous articleChecking C #
Next articleWhat is lambda expressions?

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions