var gulp = require('gulp'); var sass = require('gulp-sass'); var cleanCSS = require('gulp-clean-css'); var rename = require("gulp-rename"); var autoprefixer = require('gulp-autoprefixer'); var browserSync = require('browser-sync').create(); // Compile SCSS gulp.task('css:compile', function() { return gulp.src('./scss/**/*.scss') .pipe(sass.sync({ outputStyle: 'expanded' }).on('error', sass.logError)) .pipe(autoprefixer({ browsers: ['last 2 versions'], cascade: false })) .pipe(gulp.dest('./css')) }); // Minify CSS gulp.task('css:minify', ['css:compile'], function() { return gulp.src([ './css/*.css', '!./css/*.min.css' ]) .pipe(cleanCSS()) .pipe(rename({ suffix: '.min' })) .pipe(gulp.dest('./css')) .pipe(browserSync.stream()); }); // CSS gulp.task('css', ['css:compile', 'css:minify']); // Default task gulp.task('default', ['css']); // Configure the browserSync task gulp.task('browserSync', function() { browserSync.init({ server: { baseDir: "./" } }); }); // Dev task gulp.task('dev', ['css', 'browserSync'], function() { gulp.watch('./scss/*.scss', ['css']); gulp.watch('./*.html', browserSync.reload); });