1
restaurant-search/client/gulpfile.js

75 lines
2.2 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-09-30 07:11:54 +00:00
var sourcemaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
2014-09-26 08:14:42 +00:00
var paths = {
js: [
2014-09-30 08:40:31 +00:00
'./bower_components/underscore/underscore.js',
'./bower_components/handlebars/handlebars.js',
'./bower_components/jquery/dist/jquery.js',
'./bower_components/fabric/dist/fabric.js',
2014-09-30 08:40:31 +00:00
'./bower_components/tinycolor/tinycolor.js',
'./bower_components/bootstrap/dist/js/bootstrap.js',
'./bower_components/bootstrap-select/dist/js/bootstrap-select.js',
2014-09-30 08:40:31 +00:00
'./js/*.js'
2014-09-30 07:11:54 +00:00
],
css: [
'./bower_components/bootstrap/dist/css/bootstrap.css',
'./bower_components/bootstrap/dist/css/bootstrap-theme.css',
'./bower_components/bootstrap-select/dist/css/bootstrap-select.css',
2014-09-30 08:40:31 +00:00
'./css/*.css'
2014-09-30 07:11:54 +00:00
],
2014-09-30 07:36:48 +00:00
html: [
2014-09-30 08:40:31 +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-09-30 08:40:31 +00:00
return gulp.src('./js/*.js')
2014-09-26 08:14:42 +00:00
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('js', function() {
2014-09-26 08:14:42 +00:00
return gulp.src(paths.js)
2014-09-30 07:11:54 +00:00
.pipe(concat('scripts.js'))
2014-09-26 08:14:42 +00:00
.pipe(uglify())
.pipe(gulp.dest('./dist'));
2014-09-26 08:14:42 +00:00
});
gulp.task('css', function() {
2014-09-30 07:11:54 +00:00
return gulp.src(paths.css)
.pipe(concat('styles.css'))
.pipe(minifyCss())
.pipe(gulp.dest('./dist'));
2014-09-30 07:11:54 +00:00
});
gulp.task('html_debug', function() {
2014-09-30 07:36:48 +00:00
var sources = gulp.src(paths.js.concat(paths.css), { read: false });
return gulp.src(paths.html)
2014-09-30 09:40:42 +00:00
.pipe(inject(sources, { addRootSlash: false }))
2014-09-30 08:40:31 +00:00
.pipe(gulp.dest('./'));
2014-09-30 07:36:48 +00:00
});
gulp.task('html_release', function() {
var sources = gulp.src(['./dist/*.js', './dist/*.css'], { read: false });
return gulp.src(paths.html)
2014-09-30 09:40:42 +00:00
.pipe(inject(sources, { addRootSlash: false }))
2014-10-01 10:47:54 +00:00
.pipe(minifyHtml())
.pipe(gulp.dest('./'));
});
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']);
});
gulp.task('debug', ['lint', 'html_debug']);
gulp.task('release', ['lint', 'js', 'css', 'html_release']);
2014-09-30 09:26:57 +00:00
gulp.task('default', ['html_debug', 'watch_debug']);