-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
87 lines (78 loc) · 2.56 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
'use strict';
var gulp = require('gulp'),
concat = require('gulp-concat'),
rename = require('gulp-rename'),
del = require('del'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
minifycss = require('gulp-minify-css'),
autoprefixer = require('gulp-autoprefixer'),
imagemin = require('gulp-imagemin'),
cache = require('gulp-cache');
gulp.task('copy-bower-js', function() {
return gulp.src([
'bower_components/underscore/underscore-min.js',
'bower_components/deferred-js/js/deferred.min.js',
'bower_components/knockout/dist/knockout.js'
])
.pipe(gulp.dest('www/js'))
});
gulp.task('copy-bower-css', function() {
return gulp.src([
'bower_components/bootstrap/dist/css/bootstrap.min.css',
'bower_components/bootstrap/dist/css/bootstrap-theme.min.css',
'bower_components/fontawesome/css/font-awesome.min.css'
])
.pipe(gulp.dest('www/css'))
});
gulp.task('copy-bower-fonts', function() {
return gulp.src([
'bower_components/fontawesome/fonts/*.*'
])
.pipe(gulp.dest('www/fonts'))
});
gulp.task('copy-bower', ['copy-bower-js', 'copy-bower-css', 'copy-bower-fonts']);
gulp.task('copy', ['copy-bower']);
gulp.task('build-html', function() {
return gulp.src('src/*.html')
.pipe(gulp.dest('www'))
});
gulp.task('build-scripts', function() {
return gulp.src('src/js/**/*.js')
.pipe(concat('site.js'))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest('www/js'));
});
gulp.task('build-styles', function() {
return gulp.src('src/css/**/*.css')
.pipe(concat('site.css'))
.pipe(autoprefixer('last 2 version'))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss())
.pipe(gulp.dest('www/css'))
});
gulp.task('build-images', function() {
return gulp.src('src/images/**/*')
.pipe(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true }))
.pipe(gulp.dest('www/images'));
});
gulp.task('build', ['build-html', 'build-scripts', 'build-styles', 'build-images']);
gulp.task('copyBuild', ['copy'], function() {
return gulp.start('build');
});
gulp.task('package-cordova', function() {
return gulp.src('www/**/*')
.pipe(gulp.dest('cordova/www'));
});
gulp.task('clean', function(cb) {
return del(['www', 'cordova/www'], cb)
});
gulp.task('watch', ['build'], function() {
gulp.watch('src/**/*.html', ['build-html']);
gulp.watch('src/**/*.js', ['build-scripts']);
gulp.watch('src/**/*.css', ['build-styles']);
});
gulp.task('default', ['clean'], function() {
return gulp.start('copyBuild');
});