-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
114 lines (103 loc) · 3.06 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
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
var ngAnnotate = require('gulp-ng-annotate');
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var cssmin = require('gulp-cssmin');
var rename = require('gulp-rename');
var runSeq = require('run-sequence');
var buildLocation = './public';
var appLocation = './client';
var npmLocation = './node_modules';
var tasks = {
JS_VENDORS: 'js-vendors',
JS_APP: 'js-app',
WATCH: 'watch',
CSS_APP: 'css-app',
CSS_VENDORS: 'css-vendors',
TEMPLATES: 'templates',
IMAGES: 'images',
DEFAULT: 'default',
PRODUCTION: 'production'
};
gulp.task(tasks.JS_VENDORS, function() {
return gulp.src([
npmLocation + '/angular/angular.min.js',
npmLocation + '/angular-cookie/angular-cookie.min.js',
npmLocation + '/angular-filter/dist/angular-filter.min.js',
npmLocation + '/angular-route/angular-route.min.js',
npmLocation + '/angucomplete-alt/dist/angucomplete-alt.min.js',
npmLocation + '/jquery/dist/jquery.min.js',
npmLocation + '/masonry-layout/dist/masonry.pkgd.min.js',
npmLocation + '/moment/min/moment.min.js',
npmLocation + '/ng-token-auth/dist/ng-token-auth.min.js',
appLocation + '/shared/modernizr/modernizr.js'
])
.pipe(concat('vendors.min.js'))
.pipe(uglify())
.pipe(gulp.dest(buildLocation));
});
gulp.task(tasks.JS_APP, function() {
return gulp.src([
'!' + appLocation + '/shared/modernizr/modernizr.js',
appLocation + '/**/**.js'
])
.pipe(sourcemaps.init())
.pipe(concat('app.min.js'))
.pipe(ngAnnotate())
.pipe(uglify())
.pipe(sourcemaps.write())
.pipe(gulp.dest(buildLocation));
});
gulp.task(tasks.WATCH, function() {
gulp.watch(appLocation + '/**/**.js', [tasks.JS_APP]);
gulp.watch(appLocation + '/**/**.scss', [tasks.CSS_APP]);
gulp.watch(appLocation + '/**/**.html', [tasks.TEMPLATES]);
});
gulp.task(tasks.CSS_APP, function() {
return gulp.src(appLocation + '/index.scss')
.pipe(sass({
errLogToConsole: true
}))
.pipe(cssmin())
.pipe(rename('app.min.css'))
.pipe(gulp.dest(buildLocation));
});
gulp.task(tasks.CSS_VENDORS, function() {
return gulp.src(npmLocation + '/angucomplete-alt/angucomplete-alt.css')
.pipe(cssmin())
.pipe(rename('vendors.min.css'))
.pipe(gulp.dest(buildLocation));
});
gulp.task(tasks.TEMPLATES, function() {
return gulp.src(appLocation + '/**/**.html')
.pipe(gulp.dest(buildLocation));
});
gulp.task(tasks.IMAGES, function() {
return gulp.src(appLocation + '/**/**.{gif,png,jpeg,jpg,svg,ico}')
.pipe(gulp.dest(buildLocation));
});
gulp.task(tasks.DEFAULT, function(next) {
runSeq([
tasks.JS_VENDORS,
tasks.JS_APP,
tasks.TEMPLATES,
tasks.IMAGES,
tasks.CSS_APP,
tasks.CSS_VENDORS
],
tasks.WATCH,
next);
});
gulp.task(tasks.PRODUCTION, function(next) {
runSeq([
tasks.JS_VENDORS,
tasks.JS_APP,
tasks.TEMPLATES,
tasks.IMAGES,
tasks.CSS_APP,
tasks.CSS_VENDORS
],
next);
});