V
V
Viktor2015-12-25 22:42:10
gulp.js
Viktor, 2015-12-25 22:42:10

Why doesn't gulp update css automatically?

I use browser-sync to automatically update the browser. Html is updated as needed, but css is not, what did I do wrong and there is also a problem with the autoprefixer plugin.

'use strict';

var gulp = require('gulp'),
 	browserSync = require('browser-sync').create(),
 	sass = require('gulp-sass'),
 	rename = require("gulp-rename"),
 	watch = require('gulp-watch'),
 	notify = require("gulp-notify"),
 	autoprefixer = require('gulp-autoprefixer'),
 	minifyCss = require('gulp-minify-css');
 
gulp.task('sass', function() {
  gulp.src('*.sass') 
  	.pipe(sass()) 
    .pipe(gulp.dest(''))   	
    .pipe(minifyCss(''))
    .pipe(rename("bundle.min.css"))
    .pipe(autoprefixer({browsers: ['last 5 versions'], cascade: false}))
    .pipe(browserSync.stream())
    .pipe(notify("Gulp Done!"));
});


gulp.task('html', function() {
  gulp.src('*.html')
});


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

gulp.task('watch', function () {
    watch('*.sass', ['sass']);
    watch('*.css', ['css']).on('change', browserSync.reload);
    watch('*.html', ['html']).on('change', browserSync.reload);    
});

gulp.task('default', ['watch', 'html', 'sass' ,'browser-sync']);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
timfcsm, 2015-12-25
@timfcsm

watch should be attached to sass files... you edit them, your css remains unchanged)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question