S
S
Sergey Vasenin2019-09-01 17:48:22
Node.js
Sergey Vasenin, 2019-09-01 17:48:22

How to setup browser-sync in gulp 4?

Good time, can someone help set up browser-sync in gulp 4. before that, I set it up in gulp 3. There were no problems, but now I watched a bunch of videos and sites and didn’t understand anything. At the moment I want to set up only browser-sync without sass and stuff

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yan Markov, 2019-09-03
@emin313

const browserSync = require('browser-sync');

let config = {
    server: {
        baseDir: "./dist"
    },

    host: 'localhost',
    port: 3000,
    logPrefix: "Site"
};

gulp.task('webserver', function () {
    browserSync(config);
});

In other tasks, add after the last .pipe:
.pipe(reload({
    stream: true
}));

And don't forget about gulp.watch for files you want to watch for changes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question