T
T
Tricky_kid2019-04-19 18:07:47
gulp.js
Tricky_kid, 2019-04-19 18:07:47

How to set up Gulpfile.js?

gulpfile looks like this:

var gulp = require('gulp'),
    less = require("gulp-less");
    browserSync = require("browser-sync");

gulp.task("less", function() {
    return gulp.src("app/less/main.less")
        .pipe(less())
        .pipe(gulp.dest("app/css"))
        .pipe(browserSync.reload({stream: true}))
});

gulp.task("browser-sync", function() {
    browserSync ({
        server: {
            baseDir: "app"
        },
    });
});

gulp.task("watch", function() {
    gulp.watch("app/less/**/*.less", gulp.series("less"));
});

gulp.task("default", gulp.series(gulp.parallel("less", "browser-sync"), "watch"));

We launch
$ gulp
[18:48:19] Using gulpfile c:\Users\Ant\Desktop\HTML\Exercises\gulpfile.js
[18:48:19] Starting 'default'...
[18:48:19] Starting 'less'...
[18:48:19] Starting 'browser-sync'...
[18:48:19] Finished 'less' after 212 ms
[Browsersync] Access URLs:
-------------------------------------
Local: localhost:3000
External: 192.168.1.54:3000
-------------------------------------
UI: localhost:3001
UI External: localhost:3001
-------------------------------------
[Browsersync] Serving files from: app

As a result, watch does not work. Can you tell me what is wrong in the gulpfile?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vyach Gor, 2019-04-19
@sharnirio

as an option, the folder structure does not match and as a result, watch simply refers to non-existent folders

A
Andrey B., 2019-04-19
@andykov

There was a mistake in the default task, watch fell out

gulp.task("default", gulp.parallel("less", "browser-sync", "watch"));
// или
gulp.task("default",
    gulp.series(
        gulp.parallel("less"),
        gulp.parallel("browser-sync", "watch")
    )
);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question