1
1
'use strict' ;
2
2
/*-----------------------------------------------------------
3
- GULP: DEPENDENCIES DEFINTION
3
+ GULP: DEPENDENCIES
4
+ Define the variables of your dependencies in this section
4
5
-----------------------------------------------------------*/
5
6
var gulp = require ( 'gulp' ) ,
6
7
del = require ( 'del' ) ,
@@ -19,7 +20,8 @@ var gulp = require('gulp'),
19
20
var plugins = gulploadPlugins ( ) ;
20
21
21
22
/*-----------------------------------------------------------
22
- GULP: CONFIGURATION
23
+ GULP: APP CONFIGURATION
24
+ Source, Build folder and other application configuration
23
25
-----------------------------------------------------------*/
24
26
// Source Path
25
27
var src = {
@@ -73,37 +75,33 @@ var opts = {
73
75
74
76
// Chalk config
75
77
var error = chalk . red . bold ,
76
- warning = chalk . yellow . bold ,
77
- update = chalk . blue ,
78
+ warning = chalk . black . bold . bgYellow ,
79
+ update = chalk . yellow . underline ,
78
80
success = chalk . green ;
79
81
80
82
/*-----------------------------------------------------------
81
- GULP: TASKS
82
- -----------------------------------------------------------*/
83
- /*-----------------------------------------------------------
84
- GULP: TASKS :: List all gulp tasks
85
- -----------------------------------------------------------*/
86
-
87
- gulp . task ( 'help' , plugins . taskListing ) ;
88
-
89
- /*-----------------------------------------------------------
90
- GULP: TASKS :: Start server and live reload
83
+ GULP : APP TASKS
84
+ Necessary gulp tasks required to run your application like
85
+ magic. Feel free to add more tasks in this area
91
86
-----------------------------------------------------------*/
87
+ /*===========================================================
88
+ GULP : APP TASKS :: Start server and live reload
89
+ ===========================================================*/
92
90
93
91
gulp . task ( 'server' , function ( ) {
94
92
95
- console . log ( update ( '\n --------- Server started at http://localhost:' + serverConfiguration . port + ' ------------------------ \n' ) ) ;
93
+ console . log ( update ( '\n--------- Server started at http://localhost:' + serverConfiguration . port + ' ------------------------\n' ) ) ;
96
94
return gulp . src ( 'build' )
97
95
. pipe ( plugins . webserver ( serverConfiguration ) ) ;
98
96
} ) ;
99
97
100
- /** ================================================
101
- GULP: TASKS :: HTML -- minify html to build
102
- ===================================================*/
98
+ /*=========== ================================================
99
+ GULP : APP TASKS :: HTML -- Minify html to build
100
+ =========================================================== */
103
101
104
102
gulp . task ( 'html' , function ( ) {
105
103
106
- console . log ( update ( '\n --------- Running HTML tasks ------------------------------------------ \n ' ) ) ;
104
+ console . log ( update ( '\n--------- Running HTML tasks ------------------------------------------\n ' ) ) ;
107
105
return gulp . src ( [ src . root + '/*.html' , src . root + '/**/*.html' ] )
108
106
. pipe ( gulpIf ( production , plugins . minifyHtml ( opts ) ) )
109
107
. pipe ( plugins . fileInclude ( {
@@ -114,18 +112,18 @@ gulp.task('html', function () {
114
112
. pipe ( gulp . dest ( build . root ) ) ;
115
113
} ) ;
116
114
117
- /** ================================================
118
- GULP: TASKS :: CSS & SASS -- minify, concat
119
- ===================================================*/
115
+ /*=========== ================================================
116
+ GULP : APP TASKS :: CSS & SASS -- minify, concat
117
+ =========================================================== */
120
118
121
119
var callback = function ( err ) {
122
- console . log ( error ( '\n SASS file has error clear it to see changes, check the log below ------------- \n' ) ) ;
120
+ console . log ( error ( '\n--------- SASS file has error clear it to see changes, check the log below -------------\n' ) ) ;
123
121
console . log ( error ( err ) ) ;
124
122
} ;
125
123
126
124
gulp . task ( 'sass' , function ( ) {
127
125
128
- console . log ( update ( '\n --------- Running SASS tasks -------------------------------------------' ) ) ;
126
+ console . log ( update ( '\n--------- Running SASS tasks -------------------------------------------' ) ) ;
129
127
return gulp . src ( [ 'app/scss/master.scss' ] )
130
128
. pipe ( plugins . sass ( { onError : callback } ) )
131
129
. pipe ( plugins . size ( ) )
@@ -134,29 +132,29 @@ gulp.task('sass', function () {
134
132
135
133
gulp . task ( 'fonts' , function ( ) {
136
134
137
- console . log ( update ( '\n --------- Running Fonts tasks --------------------------------------------' ) ) ;
135
+ console . log ( update ( '\n--------- Running Fonts tasks --------------------------------------------\n ' ) ) ;
138
136
return gulp . src ( [ src . fonts + '/*.*' , src . fonts + '/**/*.*' ] )
139
137
. pipe ( plugins . size ( ) )
140
138
. pipe ( gulp . dest ( build . fonts ) ) ;
141
139
} ) ;
142
140
143
141
gulp . task ( 'css' , [ 'sass' , 'fonts' ] , function ( ) {
144
142
145
- console . log ( update ( '\n --------- Running CSS tasks --------------------------------------------' ) ) ;
143
+ console . log ( update ( '\n--------- Running CSS tasks --------------------------------------------\n ' ) ) ;
146
144
return gulp . src ( [ src . css + '/**/*.css' ] )
147
145
. pipe ( gulpIf ( production , plugins . minifyCss ( ) ) )
148
146
. pipe ( plugins . concat ( 'master.css' ) )
149
147
. pipe ( plugins . size ( ) )
150
148
. pipe ( gulp . dest ( build . css ) ) ;
151
149
} ) ;
152
150
153
- /** ================================================
154
- GULP: TASKS :: Script -- js hint & uglify & concat
155
- ===================================================*/
151
+ /*=========== ================================================
152
+ GULP: APP TASKS :: Script -- js hint, uglify & concat
153
+ =========================================================== */
156
154
157
155
gulp . task ( 'scripts' , function ( ) {
158
156
159
- console . log ( update ( '\n --------- Running SCRIPT tasks -----------------------------------------' ) ) ;
157
+ console . log ( update ( '\n--------- Running SCRIPT tasks -----------------------------------------\n ' ) ) ;
160
158
return gulp . src ( [ src . js + '/*.js' , src . js + '/**/*.js' ] )
161
159
. pipe ( plugins . jshint ( '.jshintrc' ) )
162
160
. pipe ( plugins . jshint . reporter ( jshintStylish ) )
@@ -166,13 +164,13 @@ gulp.task('scripts', function () {
166
164
. pipe ( gulp . dest ( build . js ) ) ;
167
165
} ) ;
168
166
169
- /** ================================================
170
- Concat - all bower packages
171
- ===================================================*/
167
+ /*=========== ================================================
168
+ GULP: APP TASKS :: Concat - all bower packages
169
+ =========================================================== */
172
170
173
171
gulp . task ( 'concat-bower' , function ( ) {
174
172
175
- console . log ( update ( '\n --------- Bower Concat ------------------------------------------------->>> \n' ) ) ;
173
+ console . log ( update ( '\n--------- Bower Concat -------------------------------------------------\n' ) ) ;
176
174
var jsFilter = plugins . filter ( '**/*.js' ) ,
177
175
cssFilter = plugins . filter ( '**/*.css' ) ,
178
176
fontsFilter = plugins . filter ( [ '**/fonts/**.*' ] ) ;
@@ -202,27 +200,26 @@ gulp.task('concat-bower', function () {
202
200
. pipe ( fontsFilter . restore ( ) ) ;
203
201
} ) ;
204
202
205
-
206
- /**================================================
207
- Images minification
208
- ===================================================*/
203
+ /*===========================================================
204
+ GULP: APP TASKS :: Images minification
205
+ ===========================================================*/
209
206
210
207
gulp . task ( 'img-min' , function ( ) {
211
208
212
- console . log ( update ( '\n --------- Image Minification -------------------------------------------- \n' ) ) ;
209
+ console . log ( update ( '\n--------- Image Minification --------------------------------------------\n' ) ) ;
213
210
return gulp . src ( [ src . images + '/*.*' , src . images + '/**/*.*' ] )
214
211
. pipe ( plugins . imagemin ( ) )
215
212
. pipe ( plugins . size ( ) )
216
213
. pipe ( gulp . dest ( build . images ) ) ;
217
214
} ) ;
218
215
219
- /** ===============================================
220
- Watch -- all files
221
- =================================================*/
216
+ /*============ ===============================================
217
+ GULP: APP TASKS :: Watch -- all files
218
+ =========================================================== */
222
219
223
220
gulp . task ( 'watch' , function ( ) {
224
221
225
- console . log ( update ( '\n --------- Watching All Files ------------------------------------------- \n' ) ) ;
222
+ console . log ( update ( '\n--------- Watching All Files -------------------------------------------\n' ) ) ;
226
223
var HTML = gulp . watch ( [ 'app/*.html' , 'app/**/*.html' ] , [ 'html' ] ) ,
227
224
JS = gulp . watch ( [ 'app/*.js' , 'app/js/**/*.js' ] , [ 'scripts' ] ) ,
228
225
CSS = gulp . watch ( [ 'app/*.css' , 'app/css/**/*.css' ] , [ 'css' ] ) ,
@@ -238,7 +235,7 @@ gulp.task('watch', function () {
238
235
runSequence ( 'html' , 'scripts' , 'css' , 'watch' ) ;
239
236
} , 500 ) ;
240
237
}
241
- console . log ( change ( '\n -- File ' + event . path + ' was ' + event . type + ' -->>> ' ) ) ;
238
+ console . log ( change ( '\n--------- File ' + event . path + ' was ' + event . type + ' ------------------------\n ' ) ) ;
242
239
} ;
243
240
244
241
//on change print file name and event type
@@ -251,21 +248,9 @@ gulp.task('watch', function () {
251
248
BOWER . once ( 'update' , log ) ;
252
249
} ) ;
253
250
254
- /**================================================
255
- Clean - remove files and folder in build
256
- ===================================================*/
257
-
258
- gulp . task ( 'clean' , function ( ) {
259
- console . log ( update ( '\n --------- Clean:Build Folder ------------------------------------------>>> \n' ) ) ;
260
-
261
- del ( 'build/' , function ( err ) {
262
- console . log ( update ( 'All are files deleted from the build folder' ) ) ;
263
- } ) ;
264
- } ) ;
265
-
266
- /**================================================
267
- Browser sync to sync with browser
268
- ==================================================*/
251
+ /*==========================================================
252
+ GULP: APP TASKS :: Browser sync to sync with browser
253
+ ===========================================================*/
269
254
270
255
gulp . task ( 'browser-sync' , function ( ) {
271
256
browserSync . init ( [ build . root + '*/*.*' , build . root + '**/*.*' ] ,
@@ -274,40 +259,59 @@ gulp.task('browser-sync', function () {
274
259
} ) ;
275
260
} ) ;
276
261
277
- /**================================================
278
- Zip all build files with date
279
- ==================================================*/
280
-
281
- gulp . task ( 'zip' , function ( ) {
282
- var date = new Date ( ) . toDateString ( ) ;
283
-
284
- console . log ( update ( '\n --------- Zipping Build Files ------------------------------------------>>> \n' ) ) ;
285
- return gulp . src ( [ build . root + '/**/*' ] )
286
- . pipe ( plugins . zip ( '<%= site_name %> - ' + date + '.zip' ) )
287
- . pipe ( plugins . size ( ) )
288
- . pipe ( gulp . dest ( './zip/' ) ) ;
289
- } ) ;
290
-
291
- /**===============================================
292
- Gulp build Tasks - dev, production
293
- =================================================*/
262
+ /*-----------------------------------------------------------
263
+ GULP : ENVIRONMENT
264
+ Set your environment here, as of now it's development and
265
+ production. You can also include testing and staging
266
+ -----------------------------------------------------------*/
267
+ /*==========================================================
268
+ GULP: ENVIRONMENT :: Gulp build Tasks - dev, production
269
+ ===========================================================*/
294
270
295
271
gulp . task ( 'build' , function ( ) {
296
272
297
- console . log ( update ( '\n --------- Build Development Mode -------------------------------------->>> \n' ) ) ;
273
+ console . log ( update ( '\n--------- Build Development Mode --------------------------------------\n' ) ) ;
298
274
runSequence ( 'html' , 'scripts' , 'css' , 'img-min' , 'concat-bower' , 'server' , 'watch' ) ;
299
275
} ) ;
300
276
301
277
gulp . task ( 'prod' , function ( ) {
302
278
303
- console . log ( update ( '\n --------- Build Production Mode --------------------------------------->>> \n' ) ) ;
279
+ console . log ( update ( '\n--------- Build Production Mode ---------------------------------------\n' ) ) ;
304
280
production = true ;
305
281
runSequence ( 'html' , 'scripts' , 'css' , 'img-min' , 'concat-bower' , 'server' , 'watch' ) ;
306
282
} ) ;
307
283
284
+ /*==========================================================
285
+ GULP: ENVIRONMENT :: Gulp Default Tasks -- build
286
+ ===========================================================*/
287
+
288
+ gulp . task ( 'default' , [ 'build' ] ) ;
289
+
290
+
291
+ /*-----------------------------------------------------------
292
+ GULP : HELPERS
293
+ Quick tasks to make your life easier!
294
+ -----------------------------------------------------------*/
295
+
296
+ // GULP: HELPERS :: List all gulp tasks
297
+ gulp . task ( 'help' , plugins . taskListing ) ;
298
+
299
+ // GULP: HELPERS :: Clean - remove files and folder in build
300
+ gulp . task ( 'clean' , function ( ) {
301
+ console . log ( update ( '\n--------- Clean:Build Folder ------------------------------------------\n' ) ) ;
302
+
303
+ del ( 'build/' , function ( err ) {
304
+ console . log ( update ( 'All are files deleted from the build folder' ) ) ;
305
+ } ) ;
306
+ } ) ;
308
307
309
- /**==============================================
310
- Gulp Default Tasks -- build
311
- =================================================*/
308
+ // GULP: HELPERS :: Zip all build files with date
309
+ gulp . task ( 'zip' , function ( ) {
310
+ var date = new Date ( ) . toDateString ( ) ;
312
311
313
- gulp . task ( 'default' , [ 'build' ] ) ;
312
+ console . log ( update ( '\n--------- Zipping Build Files ------------------------------------------\n' ) ) ;
313
+ return gulp . src ( [ build . root + '/**/*' ] )
314
+ . pipe ( plugins . zip ( '<%= site_name %> - ' + date + '.zip' ) )
315
+ . pipe ( plugins . size ( ) )
316
+ . pipe ( gulp . dest ( './zip/' ) ) ;
317
+ } ) ;
0 commit comments