Why not run the command gulp serve?

you have to run tasks at a time. it's silly, but otherwise the build is not working. who will help to find the error. thank you

const gulp = require('gulp');
const sass = require('gulp-sass');
const plumber = require('gulp-plumber');
const autoprefixer = require('gulp-autoprefixer');
const browserSync = require('browser-sync').create();
const sourceMaps = require('gulp-sourcemaps');

gulp.task('sass', function () { // task scss
 return gulp.src('scss/style.scss')
 .pipe(plumber()) // if there are errors in style.scss - do not disconnect, and to work further
.pipe(sourceMaps.init())
.pipe(sass())
.pipe(autoprefixer({
 browsers: ['last 2 versions']
}))
.pipe(sourceMaps.write())
 .pipe(gulp.dest('build/css')) // will create a build folder, inside it will create a css folder and in there will lie the style.css
 .pipe(browserSync.reload({stream: true})); // restart the browser, the changes in the Tasca sass
});

gulp.task('html', function () {
 return gulp.src('*.html')
.pipe(gulp.dest('build'))
 .pipe(browserSync.reload({stream: true}));
});

gulp.task('serve', function () {
browserSync.init({
 server: "build"
});
 gulp.watch("scss/**/*.scss", gulp.parallel("sass")); // to keep track of all the files in the scss folder and when you change the task to run under the name scss
 gulp.watch("*.html", gulp.parallel("html")); // the html Tusk
});

// this code is not run the command gulp serve. you have to list all three Tusk alternately.
April 3rd 20 at 18:37
2 answers
April 3rd 20 at 18:39
Solution
Add a task that will launch the desired commands for You.
gulp.task('default', gulp.series('sass', 'html', 'serve'));

This is a common practice.
But to start just use the command gulp in the console

Suitable such?
The resulting code Gulp-file

const gulp = require('gulp');
const sass = require('gulp-sass');
const plumber = require('gulp-plumber');
const autoprefixer = require('gulp-autoprefixer');
const browserSync = require('browser-sync').create();
const sourceMaps = require('gulp-sourcemaps');

gulp.task('sass', function() { // task scss
 return gulp.src('scss/style.scss')
 .pipe(plumber()) // if there are errors in style.scss - do not disconnect, and to work further
.pipe(sourceMaps.init())
.pipe(sass())
.pipe(autoprefixer({
 browsers: ['last 2 versions']
}))
.pipe(sourceMaps.write())
 .pipe(gulp.dest('build/css')) // will create a build folder, inside it will create a css folder and in there will lie the style.css
.pipe(browserSync.reload({
 stream: true
 })); // restart the browser, the changes in the Tasca sass
});

gulp.task('html', function() {
 return gulp.src('*.html')
.pipe(gulp.dest('build'))
.pipe(browserSync.reload({
 stream: true
}));
});

gulp.task('serve', function() {
browserSync.init({
 server: "build"
});
 gulp.watch("scss/**/*.scss", gulp.parallel("sass")); // to keep track of all the files in the scss folder and when you change the task to run under the name scss
 gulp.watch("*.html", gulp.parallel("html")); // the html Tusk
});

// this code is not run the command gulp serve. you have to list all three Tusk alternately.

gulp.task('default', gulp.series('sass', 'html', 'serve'));

Roman, thank You very much! class =) the project is in the build folder. Beauty! - Tracy.Gorczany commented on April 3rd 20 at 18:42
April 3rd 20 at 18:41
Can help tyk-tyk
interesting. I'll try. thank you - Tracy.Gorczany commented on April 3rd 20 at 18:44

Find more questions by tags Gulp.js