K
K
karimovcode2019-11-14 00:52:42
Sass
karimovcode, 2019-11-14 00:52:42

Automatic refresh in browser when writing code with gulp?

Hello everyone, I started using gulp
Installed (CLI version: 2.2.0 Local version: 4.0.2) also browser-sync (2.26.7)
After executing the gulp watch command in the terminal, if changes are made to the *.scss file, then *. css file changes itself.
What should I write in this code so that after executing the command in the gulp watch terminal, along with changes in
any project files, changes are also automatically updated in the browser window
Here is the code:

const gulp = require('gulp');
const sass = require('gulp-sass');
const sourcemaps = require('gulp-sourcemaps');
const watch = require('gulp-watch');

gulp.task('sass-compile', function(){
return gulp.src('./scss/**/*.scss')
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./css/'))
})

gulp.task('watch', function() {
gulp.watch('./scss/**/*.scss', gulp.series('sass-compile'))
})

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Neverov, 2019-11-14
@TTATPuOT

Use BrowserSync

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question