Created
July 2, 2014 05:33
-
-
Save yantakus/77b4b713b86011a5f632 to your computer and use it in GitHub Desktop.
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'); | |
var $ = require('gulp-load-plugins')(); | |
var options = {}; | |
options.sass = { | |
errLogToConsole: true, | |
sourceMap: 'sass', | |
sourceComments: 'map' | |
}; | |
options.autoprefixer = { | |
map: true, | |
from: 'app/styles/main.scss', | |
to: 'app/styles/main.css' | |
}; | |
gulp.task('styles', function() { | |
return gulp.src('app/styles/main.scss') | |
.pipe($.sass(options.sass)) | |
.pipe($.autoprefixer( | |
'last 2 versions', 'safari 5', 'ie 9', 'opera 12.1', 'ios 6', 'android 4', | |
options.autoprefixer | |
)) | |
.pipe(gulp.dest('.tmp/styles')) | |
.pipe($.size()); | |
}); | |
gulp.task('scripts', function () { | |
return gulp.src('app/scripts/**/*.js') | |
.pipe($.jshint()) | |
.pipe($.jshint.reporter('jshint-stylish')) | |
.pipe($.size()); | |
}); | |
gulp.task('partials', function () { | |
return gulp.src('app/partials/**/*.html') | |
.pipe($.minifyHtml({ | |
empty: true, | |
spare: true, | |
quotes: true | |
})) | |
.pipe($.ngHtml2js({ | |
moduleName: "s7", | |
prefix: "/partials/" | |
})) | |
.pipe(gulp.dest(".tmp/partials")) | |
.pipe($.size()); | |
}); | |
gulp.task('html', ['styles', 'scripts', 'partials'], function () { | |
var jsFilter = $.filter('**/*.js'); | |
var cssFilter = $.filter('**/*.css'); | |
return gulp.src('app/*.html') | |
.pipe($.inject(gulp.src('.tmp/partials/**/*.js'), { | |
read: false, | |
starttag: '<!-- inject:partials -->', | |
addRootSlash: false, | |
addPrefix: '../' | |
})) | |
.pipe($.useref.assets()) | |
.pipe($.rev()) | |
.pipe(jsFilter) | |
.pipe($.ngmin()) | |
.pipe($.uglify()) | |
.pipe(jsFilter.restore()) | |
.pipe(cssFilter) | |
.pipe($.csso()) | |
.pipe(cssFilter.restore()) | |
.pipe($.useref.restore()) | |
.pipe($.useref()) | |
.pipe($.revReplace()) | |
.pipe(gulp.dest('dist')) | |
.pipe($.size()); | |
}); | |
gulp.task('images', function () { | |
return gulp.src('app/images/**/*') | |
.pipe($.cache($.imagemin({ | |
optimizationLevel: 3, | |
progressive: true, | |
interlaced: true | |
}))) | |
.pipe(gulp.dest('dist/images')) | |
.pipe($.size()); | |
}); | |
gulp.task('fonts', function () { | |
return $.bowerFiles() | |
.pipe($.filter('**/*.{eot,svg,ttf,woff}')) | |
.pipe($.flatten()) | |
.pipe(gulp.dest('dist/fonts')) | |
.pipe($.size()); | |
}); | |
gulp.task('clean', function () { | |
return gulp.src(['.tmp', 'dist'], { read: false }).pipe($.clean()); | |
}); | |
gulp.task('build', ['html', 'partials', 'images', 'fonts']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment