-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
182 lines (156 loc) · 5.37 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
// Include gulp
var gulp = require('gulp');
// Include Our Plugins
var jshint = require('gulp-jshint');
var stylus = require('gulp-stylus');
var pugify = require('gulp-pug');
var minify = require('gulp-clean-css');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var order = require("gulp-order");
// Might be deprecated in favor of:
// https://github.com/gulpjs/gulp/blob/master/docs/recipes/delete-files-folder.md
var clean = require('gulp-clean');
var serve = require('gulp-serve');
var sequence = require('run-sequence');
var ghPages = require('gulp-gh-pages');
gulp.task('deploy', function() {
return gulp.src('dist/**/*')
.pipe(ghPages());
});
// Clean Task
gulp.task('clean', function() {
return gulp.src(['dist/*', '!dist{,/CNAME}', '!dist{,/.gitignore'], {read: false})
.pipe(clean());
});
// Tell jshint about global variables, such as 'app'
gulp.task('lint', function() {
return gulp.src(['app/app.js', 'app/config.js', 'app/controllers/*.js', 'app/factories/*.js'])
.pipe(jshint({ predef: [ 'app' ] }))
.pipe(jshint.reporter('default'));
});
// Bootstrap CSS
// gulp.task('bootstrap-styles', function() {
// return gulp.src(['app/styles/bootstrap/index.styl'])
// .pipe(stylus())
// .pipe(concat('bootstrap.min.css'))
// .pipe(minify())
// .pipe(gulp.dest('dist/styles/'));
// })
//Added for future migration to Bootstrap v4
// Bootstrap CSS
gulp.task('bootstrap-styles', function() {
return gulp.src(['node_modules/bootstrap/dist/css/bootstrap.min.css'])
.pipe(minify())
.pipe(gulp.dest('dist/styles/'));
});
// Compile To CSS
gulp.task('stylus', function () {
return gulp.src(['app/styles/*.styl', 'app/styles/*.css'])
.pipe(stylus())
.pipe(concat('all.min.css'))
.pipe(minify())
.pipe(gulp.dest('dist/styles/'));
});
// Bootstrap JS
// gulp.task('bootstrap-scripts', function() {
// return gulp.src(['app/scripts/bootstrap/*.js'])
// .pipe(order([
// "transition.js",
// "alert.js",
// "button.js",
// "carousel.js",
// "collapse.js",
// "carousel.js",
// "dropdown.js",
// "modal.js",
// "tooltip.js",
// "popover.js",
// "scrollspy.js",
// "tab.js",
// "affix.js"
// ]))
// .pipe(concat('bootstrap.min.js'))
// .pipe(uglify())
// .pipe(gulp.dest('dist/scripts/'));
// });
//Added for future migration to Bootstrap v4
gulp.task('bootstrap-scripts', function() {
return gulp.src(['node_modules/bootstrap/dist/js/bootstrap.min.js'])
.pipe(uglify())
.pipe(gulp.dest('dist/scripts/'));
});
// Concatenate & Minify JS
gulp.task('scripts', function() {
return gulp.src(['app/scripts/EasePack.min.js', 'TweenLite.min.js', 'app/scripts/wow.min.js', 'app/scripts/particles.js','app/scripts/app.js', 'app/scripts/matrix-text.js', 'app/scripts/demo.js', 'app/scripts/scrolltrigger.min.js'])
// .pipe(concat('all.min.js'))
.pipe(uglify())
.pipe(gulp.dest('dist/scripts/'));
});
// Compile To HTML
gulp.task('pug', function build() {
return gulp.src('app/views/**/*.pug')
.pipe(pugify())
.pipe(gulp.dest('dist/views/'));
});
// Copy Index and de-Pug
gulp.task('pug-index', function() {
return gulp.src('app/index.pug')
.pipe(pugify())
.pipe(gulp.dest('dist/'));
});
// Copy directives and de-Pug
gulp.task('pug-directives', function() {
return gulp.src('app/directives/**/*.pug')
.pipe(pugify())
.pipe(gulp.dest('dist/directives/'));
});
// Copy favicon.png
gulp.task('copy-favicon', function() {
return gulp.src(['app/favicon.png'])
.pipe(gulp.dest('dist/'));
});
// Copy app.js and config.js
gulp.task('copy-main', function() {
return gulp.src(['app/*.js'])
.pipe(gulp.dest('dist/'));
});
// Copy all controllers
gulp.task('copy-controllers', function() {
return gulp.src('app/controllers/*.js')
.pipe(concat('all.js'))
.pipe(gulp.dest('dist/controllers/'));
});
// Copy all directives
gulp.task('copy-directives', function() {
return gulp.src('app/directives/**/*.js')
.pipe(concat('all.js'))
.pipe(gulp.dest('dist/directives/'));
});
// Copy all fonts
gulp.task('copy-fonts', function() {
return gulp.src('app/fonts/**')
.pipe(gulp.dest('dist/fonts/'));
});
// Copy all images
gulp.task('copy-images', function() {
return gulp.src('app/images/**')
.pipe(gulp.dest('dist/images/'));
});
// Watch Files For Changes
gulp.task('watch', function() {
gulp.watch(['app/scripts/*.js'], ['lint', 'scripts']);
gulp.watch(['app/styles/*.styl', 'app/styles/*.css'], ['stylus']);
gulp.watch(['app/views/*/*.pug'], ['pug']);
gulp.watch(['app/index.pug'], ['pug-index']);
gulp.watch(['app/*.js'], ['copy-main']);
gulp.watch(['app/factories/*.js'], ['copy-factories']);
gulp.watch(['app/controllers/*.js'], ['copy-controllers']);
gulp.watch(['app/directives/*/*'], ['pug-directives', 'copy-directives']);
gulp.watch(['app/fonts/**'], ['copy-fonts']);
});
// Start development localhost server
gulp.task('serve', serve('dist'));
// Default Task
gulp.task('default', sequence(['clean'], ['lint', 'scripts', 'bootstrap-styles', 'bootstrap-scripts', 'stylus', 'pug', 'pug-index', 'pug-directives', 'copy-favicon', 'copy-main', 'copy-controllers', 'copy-directives', 'copy-fonts', 'copy-images'], ['watch'], ['serve']));