Created
June 2, 2014 11:27
-
-
Save franciscopreller/7e7d9cc74a8de0f3cf17 to your computer and use it in GitHub Desktop.
Sample gulpfile for a laravel project
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
/***** | |
* Dependencies | |
*****************/ | |
var gulp = require('gulp'), | |
sass = require('gulp-sass'), | |
uglify = require('gulp-uglify'), | |
concat = require('gulp-concat'), | |
imagemin = require('gulp-imagemin'), | |
livereload = require('gulp-livereload'); | |
/***** | |
* Configuration | |
*****************/ | |
var bases = { | |
assets: 'public/assets/', | |
// Usage: bases.dist('js'); // public/js | |
dist: function(dir) { | |
return (typeof dir === 'undefined') | |
? 'public/' | |
: 'public/' + dir; | |
} | |
}; | |
var paths = { | |
sass : bases.assets + 'sass/**/*.scss', | |
images : bases.assets + 'images/*.{png,gif,jpg}', | |
scripts: bases.assets + 'js/**/*.js', | |
views : 'app/views/**/*.php', | |
vendor : [ | |
bases.assets + 'bower_components/modernizr/modernizr.js', | |
bases.assets + 'bower_components/jquery/dist/jquery.js', | |
bases.assets + 'bower_components/fastclick/lib/fastclick.js', | |
bases.assets + 'bower_components/foundation/js/foundation.js', | |
bases.assets + 'bower_components/angular/angular.js' | |
], | |
base: function(dir) { | |
return { base: bases.assets + dir }; | |
} | |
}; | |
/***** | |
* Tasks | |
*****************/ | |
gulp | |
.task('sass', function() { | |
gulp.src(paths.sass) | |
.pipe(sass()) | |
.pipe(gulp.dest(bases.dist('css'))) | |
.pipe(livereload()); | |
}) | |
.task('components', function() { | |
gulp.src(paths.vendor, paths.base('bower_components')) | |
.pipe(uglify()) | |
.pipe(concat('vendor.min.js')) | |
.pipe(gulp.dest(bases.dist('js'))); | |
}) | |
.task('scripts', function() { | |
gulp.src(paths.scripts) | |
.pipe(uglify()) | |
.pipe(concat('scripts.min.js')) | |
.pipe(gulp.dest(bases.dist('js'))) | |
.pipe(livereload()); | |
}) | |
.task('images', function() { | |
gulp.src(paths.images) | |
.pipe(imagemin()) | |
.pipe(gulp.dest(bases.dist('img'))); | |
}) | |
.task('watch', function() { | |
var server = livereload(); | |
gulp.watch(paths.sass, ['styles']); | |
gulp.watch(paths.scripts, ['scripts']); | |
gulp.watch(paths.images, ['images']); | |
gulp.watch(paths.views).on('change', function(file) { | |
server.changed(file.path); | |
}); | |
}); | |
/***** | |
* Main task runners | |
************************/ | |
gulp | |
.task('default', [ | |
'sass', | |
'scripts', | |
'images', | |
'watch' | |
]) | |
.task('build', [ | |
'sass', | |
'scripts', | |
'images' | |
]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment