Skip to content

Instantly share code, notes, and snippets.

@martinjinda
Last active May 17, 2016 09:36
Show Gist options
  • Save martinjinda/fd0e77a8b6e9a1bfb518074694c91ff5 to your computer and use it in GitHub Desktop.
Save martinjinda/fd0e77a8b6e9a1bfb518074694c91ff5 to your computer and use it in GitHub Desktop.
Setting for compiling SCSS files + automatic refresh in browser (watching index.html + all scss files)
var gulp = require('gulp');
var browserSync = require('browser-sync');
var sass = require('gulp-sass');
var cleanCSS = require('gulp-clean-css');
gulp.task('sass', function(){
return gulp.src('dist/scss/main.scss')
.pipe(sass())
.pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(gulp.dest('src/css'))
.pipe(browserSync.reload({
stream: true
}))
});
gulp.task('browser-sync', function () {
browserSync.init(['src/css/*.css'], {
server: {
baseDir: 'src'
}
});
});
gulp.task('watch', ['sass', 'browser-sync'], function () {
gulp.watch(['dist/scss/**/*.scss'], ['sass']);
gulp.watch('src/*.html', browserSync.reload);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment