D
D
Damir Gabdrakhimov2017-02-22 14:29:01
npm
Damir Gabdrakhimov, 2017-02-22 14:29:01

How can I modify gulpfile.js so that browser-sync refreshes the page on "F5" instead of "ctrl + F5"?

Hello!
How can I modify gulpfile.js so that browser-sync refreshes the page on "F5" instead of "ctrl + F5"?
That is, I am now changing the CSS file and when saving, browser-sync updates the web page, but instead of showing the part of the page that I am typing, the page shows the header. The update occurs as if the keys "ctrl + f5" were pressed.
gulpfile.js code

var gulp = require('gulp');
var autoprefixer = require('gulp-autoprefixer');
var cleancss = require('gulp-clean-css');
var browserSync = require('browser-sync').create();

gulp.task('css', function(){
    gulp.src('./src/style.css')
    .pipe(autoprefixer({
        browsers: ['> 0.001%'],
        cascade: false
    }))
    .pipe(cleancss())
    .pipe(gulp.dest('./css')) 
    .pipe(browserSync.reload({
        stream: true
    })); 
});

gulp.task('browserSynh', function(){
    browserSync.init({
        server: {
            baseDir: './src'
        }
    })
});

gulp.task('watch', ['browserSynh'], function(){
    gulp.watch('./src/style.css', ['css']);
});

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question