Created
April 20, 2015 09:49
-
-
Save dizda/c11144f68c2d46dc9b15 to your computer and use it in GitHub Desktop.
Gulpfile.js
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
'use strict'; | |
var gulp = require('gulp'), | |
sass = require('gulp-ruby-sass'), | |
minifycss = require('gulp-minify-css'), | |
uglify = require('gulp-uglify'), | |
concat = require('gulp-concat'), | |
del = require('del'), | |
useref = require('gulp-useref'), | |
gulpif = require('gulp-if'), | |
templateCache = require('gulp-angular-templatecache'), | |
minifyHTML = require('gulp-minify-html'); | |
/** | |
* Execute all taks | |
*/ | |
gulp.task('default', ['clean'], function() { | |
//gulp.start('styles', 'scripts', 'images'); | |
gulp.start('html', 'angular-templates', 'copy-statics'); | |
}); | |
/** | |
* Remove 'dist/' directory before starting | |
*/ | |
gulp.task('clean', function(cb) { | |
del(['dist/'], cb); | |
}); | |
/** | |
* - Take all CSS and JS specified in index.html | |
* - minify css | |
* - concat them | |
* - minify the index.html | |
*/ | |
gulp.task('html', function () { | |
var assets = useref.assets(); | |
return gulp.src('public/index.html') | |
.pipe(assets) | |
.pipe(gulpif('*.js', uglify())) | |
.pipe(gulpif('*.css', minifycss())) | |
.pipe(assets.restore()) | |
.pipe(useref()) | |
.pipe(gulpif('*.html', minifyHTML({ | |
conditionals: true // do not remove IE conditional comments | |
}))) | |
.pipe(gulp.dest('dist')) | |
; | |
}); | |
/** | |
* Concat all angular templates into JS angular-cache | |
*/ | |
gulp.task('angular-templates', function () { | |
return gulp.src('public/js/**/*.html') | |
.pipe(minifyHTML()) | |
.pipe(templateCache('assets/templates.js', { | |
module: 'app', // use app module instead of templates | |
standalone: false, | |
root: '/js/' // specify that templates name begins with /js/ directory | |
})) | |
.pipe(gulp.dest('dist')) | |
; | |
}); | |
/** | |
* Copy statics to dist directory | |
*/ | |
gulp.task('copy-statics', function () { | |
gulp.src('public/components/fontawesome/fonts/*') | |
.pipe(gulp.dest('dist/fonts')) | |
; | |
gulp.src('public/components/html5shiv/dist/html5shiv.min.js') | |
.pipe(gulp.dest('dist/components/html5shiv/dist')) | |
; | |
gulp.src('public/components/respond/dest/respond.min.js') | |
.pipe(gulp.dest('dist/components/respond/dest')) | |
; | |
gulp.src('public/images/*') | |
.pipe(gulp.dest('dist/images')) | |
; | |
}); | |
//// Images | |
//gulp.task('images', function() { | |
// return gulp.src('src/images/**/*') | |
// .pipe(cache(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true }))) | |
// .pipe(gulp.dest('dist/images')) | |
// .pipe(notify({ message: 'Images task complete' })); | |
//}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment