Answer the question
In order to leave comments, you need to log in
GULP Reloading Browsers... Website not updating when writing and saving code. How to fix?
var gulp = require('gulp'),
minifyCSS = require('gulp-clean-css'),
rename = require('gulp-rename'),
sass = require('gulp-sass'),
minifyJS = require('gulp-minify'),
browserSync = require('browser-sync').create();
gulp.task('minCss', function() {
gulp.src('app/css/*.scss')
.pipe(sass())
.pipe(minifyCSS())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('public/css'))
.pipe(browserSync.stream());
});
gulp.task('minJs', function() {
gulp.src('app/js/main.js')
.pipe(minifyJS())
.pipe(gulp.dest('public/js'))
.pipe(browserSync.stream());
});
gulp.task('watchAll', function() {
gulp.watch("app/css/*.scss", gulp.series('minCss'));
gulp.watch("app/js/*.js", gulp.series('minJs'));
});
gulp.task('browserSync', function() {
browserSync.init({
server: "public/"
});
gulp.watch("public/*.html").on('change', browserSync.reload);
});
gulp.task('default', gulp.parallel('browserSync', 'watchAll'));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question