Created
June 20, 2014 07:33
-
-
Save anonymous/7047dd5d2dc1a27b027c 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
'use strict'; | |
// generated on 2014-06-20 using generator-gulp-webapp 0.1.0 | |
var gulp = require('gulp'); | |
var browserSync = require('browser-sync'); | |
var reload = browserSync.reload; | |
// load plugins | |
var $ = require('gulp-load-plugins')(); | |
gulp.task('styles', function () { | |
return gulp.src('app/styles/main.scss') | |
.pipe($.rubySass({ | |
style: 'expanded', | |
precision: 10 | |
})) | |
.pipe($.autoprefixer('last 1 version')) | |
.pipe(gulp.dest('.tmp/styles')) | |
.pipe(reload({stream:true})) | |
.pipe($.size()); | |
}); | |
gulp.task('scripts', function () { | |
return gulp.src('app/scripts/**/*.js') | |
.pipe($.jshint()) | |
.pipe($.jshint.reporter(require('jshint-stylish'))) | |
.pipe(reload({stream:true, once:true})) | |
.pipe($.size()); | |
}); | |
gulp.task('html', ['styles', 'scripts'], function () { | |
var jsFilter = $.filter('**/*.js'); | |
var cssFilter = $.filter('**/*.css'); | |
return gulp.src('app/*.html') | |
.pipe($.useref.assets({searchPath: '{.tmp,app}'})) | |
.pipe(jsFilter) | |
.pipe($.uglify()) | |
.pipe(jsFilter.restore()) | |
.pipe(cssFilter) | |
.pipe($.csso()) | |
.pipe(cssFilter.restore()) | |
.pipe($.useref.restore()) | |
.pipe($.useref()) | |
.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(reload({stream:true})) | |
.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('extras', function () { | |
return gulp.src(['app/*.*', '!app/*.html'], { dot: true }) | |
.pipe(gulp.dest('dist')); | |
}); | |
gulp.task('clean', function () { | |
return gulp.src(['.tmp', 'dist'], { read: false }).pipe($.clean()); | |
}); | |
gulp.task('build', ['html', 'images', 'fonts', 'extras']); | |
gulp.task('default', ['clean'], function () { | |
gulp.start('build'); | |
}); | |
gulp.task('bs-start', function () { | |
browserSync.init({ | |
server: { | |
baseDir: ["app", ".tmp"] | |
} | |
}); | |
}); | |
gulp.task('serve', ['bs-start', 'styles']); | |
// inject bower components | |
gulp.task('wiredep', function () { | |
var wiredep = require('wiredep').stream; | |
gulp.src('app/styles/*.scss') | |
.pipe(wiredep({ | |
directory: 'app/bower_components' | |
})) | |
.pipe(gulp.dest('app/styles')); | |
gulp.src('app/*.html') | |
.pipe(wiredep({ | |
directory: 'app/bower_components', | |
exclude: ['bootstrap-sass-official'] | |
})) | |
.pipe(gulp.dest('app')); | |
}); | |
gulp.task('watch', ['serve'], function () { | |
// watch for changes | |
gulp.watch(['app/*.html'], reload); | |
gulp.watch('app/styles/**/*.scss', ['styles']); | |
gulp.watch('app/scripts/**/*.js', ['scripts']); | |
gulp.watch('app/images/**/*', ['images']); | |
gulp.watch('bower.json', ['wiredep']); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment