Created
July 20, 2016 01:09
-
-
Save searleb/50079734eafd5e854bd04d1450bae4b5 to your computer and use it in GitHub Desktop.
Gulp - BrowserSync, Sass -> Css, Imagemin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
var browserSync = require('browser-sync').create(); | |
var sass = require('gulp-sass'); | |
var rename = require('gulp-rename'); | |
var imagemin = require('gulp-imagemin'); | |
// Static Server + watching scss/html files | |
gulp.task('serve', ['sass'], function() { | |
browserSync.init({ | |
proxy: 'docker.dev' | |
}); | |
gulp.watch('www/scss/main.scss', ['sass']); | |
gulp.watch('application/views/**/*.php').on('change', browserSync.reload); | |
}); | |
// Compile sass into CSS & auto-inject into browsers | |
gulp.task('sass', function() { | |
return gulp.src('www/scss/main.scss') | |
.pipe(sass({ | |
outputStyle: 'compressed' | |
}).on('error', sass.logError)) | |
.pipe(rename('style.css')) | |
.pipe(gulp.dest('www/css')) | |
.pipe(browserSync.stream()); | |
}); | |
// Imagemin | |
gulp.task('imagemin', function() { | |
gulp.src('www/images/**/*') | |
.pipe(imagemin()) | |
.pipe(gulp.dest('www/images')); | |
}); | |
gulp.task('build', ['imagemin']); | |
gulp.task('default', ['serve']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment