Created
February 13, 2015 08:50
-
-
Save xar/fd4c1b053b8aa00d44b6 to your computer and use it in GitHub Desktop.
gulpfile
This file contains hidden or 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'); | |
var plumber = require('gulp-plumber'); | |
var reload = browserSync.reload; | |
var sass = require('gulp-sass'); | |
var autoprefixer = require('gulp-autoprefixer'); | |
var minifycss = require('gulp-minify-css'); | |
var rename = require('gulp-rename'); | |
var watch = require('gulp-watch'); | |
var concat = require('gulp-concat'); | |
function swallowError (error) { | |
//If you want details of the error in the console | |
console.log(error.toString()); | |
this.emit('end'); | |
} | |
// browser-sync task for starting the server. | |
gulp.task('browser-sync', function() { | |
browserSync({ | |
proxy: "127.0.0.1" | |
}); | |
}); | |
// Sass task, will run when any SCSS files change & BrowserSync | |
// will auto-update browsers | |
gulp.task('sass', function () { | |
return gulp.src('./assets/sass/**/*.scss') | |
.pipe(plumber()) | |
.pipe(sass({ style: 'expanded'})) | |
.on('error', swallowError) | |
.pipe(autoprefixer('last 10 version', 'safari 5', 'ie 8', 'ie 9', 'opera 11.1')) | |
.pipe(gulp.dest('./assets/css')) | |
.pipe(rename({suffix: '.min'})) | |
.pipe(minifycss()) | |
.pipe(gulp.dest('./assets/css')) | |
.pipe(reload({stream:true})); | |
}); | |
gulp.task('lara', function(){ | |
return gulp.src('./www/views/**') | |
.on('error', swallowError) | |
.pipe(reload({stream:true})); | |
}); | |
gulp.task('js', function(){ | |
return gulp.src(['./assets/js/**', './fancybox/jquery.fancybox.pack.js']) | |
//.pipe(concat('build.js')) | |
//.pipe(gulp.dest('./assets/js/')) | |
.on('error', swallowError) | |
.pipe(reload({stream:true})); | |
}); | |
gulp.task('watch', function(){ | |
}); | |
// Default task to be run with `gulp` | |
gulp.task('default', ['sass', 'browser-sync', 'js'], function () { | |
watch('./assets/sass/**/*.scss', function() { | |
gulp.start('sass'); | |
}); | |
watch('./assets/js/*.js', function() { | |
gulp.start('js'); | |
}); | |
watch('./www/views/**', function() { | |
gulp.start('lara'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment