Skip to content

Instantly share code, notes, and snippets.

@tw15egan
Created February 18, 2016 18:33
Show Gist options
  • Save tw15egan/7c3e2d1985d16dd65442 to your computer and use it in GitHub Desktop.
Save tw15egan/7c3e2d1985d16dd65442 to your computer and use it in GitHub Desktop.
Simple Gulpfile for quick projects
"use strict";
var gulp = require('gulp'),
rename = require('gulp-rename'),
sass = require('gulp-sass'),
browserSync = require('browser-sync').create(),
autoprefixer = require('gulp-autoprefixer'),
nano = require('gulp-cssnano'),
maps = require('gulp-sourcemaps');
gulp.task('compileSass', function() {
return gulp.src("./scss/application.scss")
.pipe(maps.init())
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(nano())
.pipe(rename('styles.min.css'))
.pipe(maps.write('./'))
.pipe(gulp.dest('css'))
.pipe(browserSync.stream());
});
gulp.task('watchFiles', function() {
browserSync.init({
server: {
baseDir: "./"
}
});
gulp.watch("*.html").on('change', browserSync.reload);
gulp.watch('./scss/**/*.scss', ['compileSass']);
gulp.watch('js/*.js').on('change', browserSync.reload);
})
gulp.task('watch', ['watchFiles']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment