Created
November 17, 2014 22:48
-
-
Save stones/7939207ff1b399da938e to your computer and use it in GitHub Desktop.
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'), | |
del = require('del'), | |
less = require('gulp-less'), | |
gutil = require('gulp-util'), | |
coffee = require('gulp-coffee'), | |
uglify = require('gulp-uglify'), | |
notify = require('gulp-notify'), | |
minifycss = require('gulp-minify-css'), | |
autoprefixer = require('gulp-autoprefixer'), | |
gulpFilter = require('gulp-filter'), | |
livereload = require('gulp-livereload'), | |
mainBowerFiles = require('main-bower-files'); | |
var paths = { | |
base: { | |
prod: 'public/static', | |
dev : 'static' | |
}, | |
dev: function (folder) { | |
return this.getPath(this.base.dev, folder); | |
}, | |
devFilters: function (type) { | |
switch (type) { | |
case 'styles': | |
return this.getPath(this.dev('styles'), '*.less'); | |
case 'scripts': | |
return this.getPath(this.dev('scripts'), '*.coffee'); | |
case 'images': | |
return this.getPath(this.dev('images'), '**/*'); | |
} | |
}, | |
prod: function (folder) { | |
return this.getPath(this.base.prod, folder); | |
}, | |
watch: function () { | |
return ['app/**', 'public/**', '!app/storage/**']; | |
}, | |
getPath: function (base, folder) { | |
return base + '/' + folder; | |
} | |
}; | |
gulp.task("bower", function () { | |
var jsFilter = gulpFilter('**/*.js', '!**/*.min.js'); | |
gulp.src(mainBowerFiles({paths: {bowerDirectory: 'static/vendor'}})) | |
.pipe(jsFilter) | |
.pipe(uglify()) | |
.pipe(gulp.dest(paths.prod('vendor/'))) | |
.pipe(notify({message: 'Bower scripts complete'})); | |
gulp.src('static/vendor/font-awesome/fonts/*') | |
.pipe(gulp.dest(paths.prod('fonts/font-awesome/'))) | |
.pipe(notify({message: 'Font Awesome moved'})); | |
gulp.src('static/vendor/open-sans-fontface/fonts/**/*') | |
.pipe(gulp.dest(paths.prod('fonts/open-sans/'))) | |
.pipe(notify({message: 'Open Sans moved'})); | |
}); | |
// Styles | |
gulp.task('styles', function () { | |
return gulp.src(paths.devFilters('styles')) | |
.pipe(less()) | |
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4')) | |
.pipe(minifycss()) | |
.pipe(gulp.dest(paths.prod('styles'))) | |
.pipe(notify({message: 'Styles task complete'})); | |
}); | |
// | |
gulp.task('scripts', function () { | |
return gulp.src(paths.devFilters('scripts')) | |
.pipe(coffee({bare: true})).on('error', gutil.log) | |
.pipe(uglify()) | |
.pipe(gulp.dest(paths.prod('scripts'))) | |
.pipe(notify({message: 'scripts task complete'})); | |
}); | |
//images | |
gulp.task('images', function () { | |
return gulp.src(paths.devFilters('images')) | |
.pipe(gulp.dest(paths.prod('images'))) | |
.pipe(notify({message: 'Image moved'})); | |
}); | |
// Clean | |
gulp.task('clean', function (cb) { | |
return del([paths.prod('')], cb) | |
}); | |
// Default task | |
gulp.task('default', ['clean'], function () { | |
return gulp.start('bower', 'styles', 'scripts', 'images'); | |
}); | |
// Watch | |
gulp.task('watch', function () { | |
// Watch .less files | |
gulp.watch(paths.devFilters('styles'), ['styles']); | |
// Watch .js files | |
gulp.watch(paths.devFilters('scripts'), ['scripts']); | |
// Watch image files | |
gulp.watch(paths.devFilters('images'), ['images']); | |
// Create LiveReload server | |
livereload.listen(); | |
// Watch any files in dist/, reload on change | |
gulp.watch(paths.watch()).on('change', livereload.changed); | |
}); |
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
{ | |
"name" : "Melb.IT.ES.Orca", | |
"version" : "0.0.1", | |
"devDependencies": { | |
"del" : "^0.1.3", | |
"gulp" : "^3.4.0", | |
"gulp-autoprefixer": "^1.0.1", | |
"gulp-bower-files" : "^0.2.7", | |
"gulp-coffee" : "^2.2.0", | |
"gulp-concat" : "^2.4.1", | |
"gulp-filter" : "^1.0.2", | |
"gulp-less" : "^1.3.6", | |
"gulp-livereload" : "^2.1.1", | |
"gulp-minify-css" : "^0.3.11", | |
"gulp-notify" : "^2.0.0", | |
"gulp-uglify" : "^1.0.1", | |
"gulp-util" : "^3.0.1", | |
"main-bower-files" : "^2.1.0", | |
"matchdep" : "~0.3.0" | |
}, | |
"engines" : { | |
"node": ">=0.8.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment