1
restaurant-search/client/gulpfile.js

94 lines
2.8 KiB
JavaScript
Raw Normal View History

2014-09-30 07:11:54 +00:00
var concat = require('gulp-concat');
var gulp = require('gulp');
2014-09-30 07:36:48 +00:00
var inject = require('gulp-inject');
2014-09-30 07:11:54 +00:00
var jshint = require('gulp-jshint');
var minifyCss = require('gulp-minify-css');
2014-10-01 10:47:54 +00:00
var minifyHtml = require('gulp-minify-html');
2014-10-02 04:14:22 +00:00
var replace = require('gulp-replace');
2014-09-30 07:11:54 +00:00
var uglify = require('gulp-uglify');
2014-09-26 08:14:42 +00:00
var paths = {
2014-10-02 03:58:12 +00:00
scripts: [
2014-10-02 04:20:54 +00:00
'bower_components/underscore/underscore.js',
'bower_components/handlebars/handlebars.js',
'bower_components/jquery/dist/jquery.js',
'bower_components/fabric/dist/fabric.js',
'bower_components/tinycolor/tinycolor.js',
'bower_components/bootstrap/dist/js/bootstrap.js',
'bower_components/bootstrap-select/dist/js/bootstrap-select.js',
'scripts/*.js'
2014-09-30 07:11:54 +00:00
],
2014-10-02 03:58:12 +00:00
styles: [
2014-10-02 04:20:54 +00:00
'bower_components/bootstrap/dist/css/bootstrap.css',
'bower_components/bootstrap/dist/css/bootstrap-theme.css',
'bower_components/bootstrap-select/dist/css/bootstrap-select.css',
'styles/*.css'
2014-09-30 07:11:54 +00:00
],
2014-10-01 11:02:27 +00:00
fonts: [
2014-10-02 04:20:54 +00:00
'bower_components/bootstrap/fonts/*'
2014-10-01 11:02:27 +00:00
],
2014-10-02 04:14:22 +00:00
images: [
2014-10-02 04:20:54 +00:00
'images/*'
2014-10-02 04:14:22 +00:00
],
2014-09-30 07:36:48 +00:00
html: [
2014-10-02 04:20:54 +00:00
'html/*.html'
2014-09-30 07:36:48 +00:00
]
2014-09-26 08:14:42 +00:00
};
gulp.task('lint', function() {
2014-10-02 06:45:46 +00:00
gulp.src('scripts/*.js')
2014-09-26 08:14:42 +00:00
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
2014-10-02 04:14:22 +00:00
gulp.task('images', function() {
return gulp.src(paths.images)
2014-10-02 04:20:54 +00:00
.pipe(gulp.dest('dist/images'));
2014-10-02 04:14:22 +00:00
});
2014-10-01 11:02:27 +00:00
gulp.task('fonts', function() {
return gulp.src(paths.fonts)
2014-10-02 04:20:54 +00:00
.pipe(gulp.dest('dist/fonts'));
2014-10-01 11:02:27 +00:00
});
2014-10-02 03:58:12 +00:00
gulp.task('scripts', function() {
return gulp.src(paths.scripts)
2014-09-30 07:11:54 +00:00
.pipe(concat('scripts.js'))
2014-09-26 08:14:42 +00:00
.pipe(uglify())
2014-10-02 04:20:54 +00:00
.pipe(gulp.dest('dist'));
2014-09-26 08:14:42 +00:00
});
2014-10-02 03:58:12 +00:00
gulp.task('styles', function() {
return gulp.src(paths.styles)
2014-10-02 04:14:22 +00:00
.pipe(replace('../fonts/', './fonts/'))
2014-09-30 07:11:54 +00:00
.pipe(concat('styles.css'))
.pipe(minifyCss())
2014-10-02 04:20:54 +00:00
.pipe(gulp.dest('dist'));
2014-09-30 07:11:54 +00:00
});
gulp.task('html_debug', function() {
2014-10-02 03:58:12 +00:00
var sources = gulp.src(paths.scripts.concat(paths.styles), { read: false });
2014-09-30 07:36:48 +00:00
return gulp.src(paths.html)
2014-10-02 04:20:54 +00:00
.pipe(replace('images/', '../images/'))
2014-10-02 03:58:12 +00:00
.pipe(inject(sources, { addRootSlash: false, addPrefix: '..' }))
2014-10-02 04:20:54 +00:00
.pipe(gulp.dest('dev'));
2014-09-30 07:36:48 +00:00
});
gulp.task('html_release', ['scripts', 'styles'], function() {
2014-10-02 04:20:54 +00:00
var sources = gulp.src(['dist/*.js', 'dist/*.css'], { read: false });
return gulp.src(paths.html)
2014-10-02 03:58:12 +00:00
.pipe(inject(sources, { addRootSlash: false, ignorePath: 'dist' }))
2014-10-01 10:47:54 +00:00
.pipe(minifyHtml())
2014-10-02 04:20:54 +00:00
.pipe(gulp.dest('dist'));
});
2014-09-30 09:26:57 +00:00
gulp.task('watch_debug', function() {
2014-09-30 09:10:48 +00:00
gulp.watch(paths.html, ['html_debug']);
2014-10-02 04:20:54 +00:00
gulp.watch(paths.scripts, ['lint']);
2014-09-30 09:10:48 +00:00
});
2014-10-02 03:58:12 +00:00
gulp.task('debug', ['lint', 'html_debug']);
2014-10-02 04:14:22 +00:00
gulp.task('release', ['lint', 'fonts', 'images', 'scripts', 'styles', 'html_release']);
2014-10-02 03:58:12 +00:00
gulp.task('all', ['debug', 'release']);
2014-10-02 04:20:54 +00:00
gulp.task('default', ['debug', 'watch_debug']);