Skip to content

Instantly share code, notes, and snippets.

@nmabhinandan
Last active August 29, 2015 14:13
Show Gist options
  • Save nmabhinandan/084d95fc7ed3e7942981 to your computer and use it in GitHub Desktop.
Save nmabhinandan/084d95fc7ed3e7942981 to your computer and use it in GitHub Desktop.
My gulp runner
var gulp = require('gulp');
var elixir = require('laravel-elixir');
var concat = require('gulp-concat');
var compass = require('gulp-compass');
var filter = require('gulp-filter');
var mainBowerFiles = require('main-bower-files');
var browserSync = require('browser-sync');
var order = require("gulp-order");
// var notify = require("gulp-notify");
/**
* Lauch a live reload server
*
*/
gulp.task('browser-sync', function() {
browserSync({
proxy: "softjob.app",
});
});
gulp.task('reload', function() {
browserSync.reload();
});
/**
* Laravel specific tasks
*
*/
gulp.task('laravel', function() {
elixir(function(mix) {
mix.events().routes();
});
});
/**
* Compile sass files using compass and minify generated css
*
*/
gulp.task('compass', function() {
gulp.src('./resources/assets/sass/*.scss')
.pipe(compass({
config_file: './config.rb',
css: 'public/css',
sass: 'resources/assets/sass'
}))
.pipe(gulp.dest('./public/css'));
// .pipe(browserSync.reload({stream:true}));
});
/**
* Merge and uglify js files
*
*/
gulp.task('js', function() {
gulp.src(['./public/js/modules.js', './public/js/services/*.js', './public/js/controllers/*.js', './public/js/directives/*.js', './public/js/intl.js'])
.pipe(concat('app.js'))
.pipe(gulp.dest('./public/js'));
});
/**
* Filter and merge bower dependencies
*
*/
var filterByExtension = function(extension){
return filter(function(file){
return file.path.match(new RegExp('.' + extension + '$'));
});
};
gulp.task('bower', function(){
var mainFiles = mainBowerFiles();
if(!mainFiles.length){
return;
}
var jsFilter = filterByExtension('js');
return gulp.src(mainFiles)
.pipe(jsFilter)
.pipe(concat('lib.js'))
.pipe(gulp.dest('./public/js/lib'))
.pipe(jsFilter.restore())
.pipe(filterByExtension('css'))
.pipe(concat('lib.css'))
.pipe(gulp.dest('./public/css'));
});
/**
* Watch for file changes and fire appropriate actions
*
*/
gulp.task('watch', function() {
gulp.watch('./resources/assets/sass/**/*.scss', ['sass']);
gulp.watch('./public/js/**/*.js', ['js']);
// gulp.watch('./public/**/*.html', ['reload']);
gulp.watch('./app/*.php', ['laravel']);
});
gulp.task('default', ['compass', 'bower', 'js', 'watch']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment