-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
121 lines (107 loc) · 3.68 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
var gulp = require('gulp');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var notify = require('gulp-notify');
var htmlreplace = require('gulp-html-replace');
var minifiy_css = require('gulp-minify-css');
var main_bower = require('main-bower-files');
var filter = require('gulp-filter');
var bower_dir = 'public/js/lib/vendor/bower_components';
/**
Starting point for gulp... the default task is a blank task depending on the array passed in
*/
gulp.task('default', ['minify-js', 'replace-js', 'minify-css', 'replace-css', 'minify-bower', 'replace-bower', 'minify-libs', 'replace-libs']);
/****************************************
Minify
*****************************************/
/**
These are all js files from winstonApp
*/
gulp.task('minify-js', function() {
return gulp.src(['public/js/app.js', 'public/js/controllers/*.js', 'public/js/services/*.js'])
.pipe(concat('app.min.js'))
.pipe(uglify())
.pipe(gulp.dest('public/js/app-min'))
.pipe(notify({ message: 'Finished minifying app (excluding bower)'}));
});
/**
Make sure to manually add new css libs here
*/
gulp.task('minify-css', function() {
return gulp.src([bower_dir + '/normalize.css/normalize.css',
bower_dir + '/bootstrap/dist/css/bootstrap.css',
bower_dir + '/angular-material/angular-material.css',
bower_dir + '/fullcalendar/dist/fullcalendar.css',
bower_dir + '/ngprogress-lite/ngprogress-lite.css',
bower_dir + '/angular-socialshare/angular-socialshare.css',
bower_dir + '/ngDialog/css/ngDialog.css',
'public/css/style.css'])
.pipe(concat('css.min.css'))
.pipe(minifiy_css())
.pipe(gulp.dest('public/css/css-min'))
.pipe(notify({ message: 'Finished minifying css'}));
});
/**
This grabs all main bower js files...if its in bower, its included in here
*/
gulp.task('minify-bower', function() {
var jsFilter = filter('*.js')
return gulp.src(main_bower())
.pipe(jsFilter)
.pipe(concat('bower.min.js'))
.pipe(uglify())
.pipe(gulp.dest('public/js/bower/bower-min'))
.pipe(notify({ message: 'Finished minifying bower'}))
.pipe(jsFilter.restore());
});
/**
Make sure to manually add new libs into this!
*/
gulp.task('minify-libs', function() {
return gulp.src(['public/js/lib/calendar.js',
'public/js/lib/filterStabilize.js',
'public/js/lib/fuse.min.js',
'public/js/lib/memoize.js',
'public/js/lib/twitter.min.js'
])
.pipe(concat('libs.min.js'))
.pipe(uglify())
.pipe(gulp.dest('public/js/libs/libs-min'))
.pipe(notify({ message: 'Finished minifying libs'}));
});
/****************************************
Replace
*****************************************/
gulp.task('replace-libs', ['minify-libs'], function() {
return gulp.src('views/libs.html')
.pipe(htmlreplace({
'js': 'js/libs/libs-min/libs.min.js'
}))
.pipe(notify({ message: 'Finished replacing libs in html'}))
.pipe(gulp.dest('views/build'));
})
gulp.task('replace-bower', ['minify-bower'], function() {
gulp.src('views/bower.html')
.pipe(htmlreplace({
'js': 'js/bower/bower-min/bower.min.js'
}))
.pipe(notify({ message: 'Finished replacing bower in html'}))
.pipe(gulp.dest('views/build'));
});
gulp.task('replace-js', ['minify-js'], function() {
gulp.src('views/includes.html')
.pipe(htmlreplace({
'js': 'js/app-min/app.min.js'
}))
.pipe(notify({ message: 'Finished replacing js in html'}))
.pipe(gulp.dest('views/build'));
});
gulp.task('replace-css', ['minify-css'], function() {
gulp.src('views/styles.html')
.pipe(htmlreplace({
'css': 'css/css-min/css.min.css'
}))
.pipe(notify({ message: 'Finished replacing css in html'}))
.pipe(gulp.dest('views/build'));
});