@@ -68,7 +68,7 @@ function onServerLog(log) {
68
68
function checkAppReady ( cb ) {
69
69
var options = {
70
70
host : 'localhost' ,
71
- port : config . port ,
71
+ port : config . port
72
72
} ;
73
73
http
74
74
. get ( options , ( ) => cb ( true ) )
@@ -80,7 +80,7 @@ function whenServerReady(cb) {
80
80
var serverReady = false ;
81
81
var appReadyInterval = setInterval ( ( ) =>
82
82
checkAppReady ( ( ready ) => {
83
- if ( ! ready || serverReady ) {
83
+ if ( ! ready || serverReady ) {
84
84
return ;
85
85
}
86
86
clearInterval ( appReadyInterval ) ;
@@ -123,6 +123,32 @@ let transpile = lazypipe()
123
123
. pipe ( plugins . coffee , { bare : true } ) < % } % >
124
124
. pipe ( plugins . sourcemaps . write , '.' ) ; < % } % >
125
125
126
+ /********************
127
+ * Env
128
+ ********************/
129
+
130
+ gulp . task ( 'env:all' , ( ) => {
131
+ let localConfig ;
132
+ try {
133
+ localConfig = require ( './server/config/local.env' ) ;
134
+ } catch ( e ) {
135
+ localConfig = { } ;
136
+ }
137
+ plugins . env ( {
138
+ vars : localConfig
139
+ } ) ;
140
+ } ) ;
141
+ gulp . task ( 'env:test' , ( ) => {
142
+ plugins . env ( {
143
+ vars : { NODE_ENV : 'test' }
144
+ } ) ;
145
+ } ) ;
146
+ gulp . task ( 'env:prod' , ( ) => {
147
+ plugins . env ( {
148
+ vars : { NODE_ENV : 'production' }
149
+ } ) ;
150
+ } ) ;
151
+
126
152
/********************
127
153
* Tasks
128
154
********************/
@@ -135,8 +161,8 @@ gulp.task('inject:js', () => {
135
161
return gulp . src ( paths . client . mainView )
136
162
. pipe ( plugins . inject (
137
163
gulp . src ( _ . union ( paths . client . scripts , [ '!client/**/*.spec.<%= scriptExt %>' ] ) , { read : false } )
138
- . pipe ( plugins . sort ( ) )
139
- , {
164
+ . pipe ( plugins . sort ( ) ) ,
165
+ {
140
166
starttag : '<!-- injector:js -->' ,
141
167
endtag : '<!-- endinjector -->' ,
142
168
transform : ( filepath ) => '<script src="' + filepath . replace ( '/client/' , '' ) + '"></script>'
@@ -148,8 +174,8 @@ gulp.task('inject:css', () => {
148
174
return gulp . src ( paths . client . mainView )
149
175
. pipe ( plugins . inject (
150
176
gulp . src ( '/client/**/*.css' , { read : false } )
151
- . pipe ( plugins . sort ( ) )
152
- , {
177
+ . pipe ( plugins . sort ( ) ) ,
178
+ {
153
179
starttag : '<!-- injector:css -->' ,
154
180
endtag : '<!-- endinjector -->' ,
155
181
transform : ( filepath ) => '<link rel="stylesheet" href="' + filepath . replace ( '/client/' , '' ) . replace ( '/.tmp/' , '' ) + '">'
@@ -161,8 +187,8 @@ gulp.task('inject:<%= styleExt %>', () => {
161
187
return gulp . src ( 'client/app/app.<%= styleExt %>' )
162
188
. pipe ( plugins . inject (
163
189
gulp . src ( _ . union ( paths . client . styles , [ '!' + paths . client . mainStyle ] ) , { read : false } )
164
- . pipe ( plugins . sort ( ) )
165
- , {
190
+ . pipe ( plugins . sort ( ) ) ,
191
+ {
166
192
starttag : '// injector' ,
167
193
endtag : '// endinjector' ,
168
194
transform : ( filepath ) => {
@@ -289,7 +315,7 @@ gulp.task('mocha:unit', () => {
289
315
'./mocha.conf'
290
316
]
291
317
} ) )
292
- . once ( 'end' , function ( ) {
318
+ . once ( 'end' , function ( ) {
293
319
process . exit ( ) ;
294
320
} ) ;
295
321
} ) ;
@@ -380,7 +406,10 @@ gulp.task('build:client', ['transpile:client', 'styles', 'html'], () => {
380
406
. pipe ( plugins . uglify ( ) )
381
407
. pipe ( jsFilter . restore ( ) )
382
408
. pipe ( cssFilter )
383
- . pipe ( plugins . minifyCss ( { cache : true , processImportFrom : [ '!fonts.googleapis.com' ] } ) )
409
+ . pipe ( plugins . minifyCss ( {
410
+ cache : true ,
411
+ processImportFrom : [ '!fonts.googleapis.com' ]
412
+ } ) )
384
413
. pipe ( cssFilter . restore ( ) )
385
414
. pipe ( plugins . rev ( ) )
386
415
. pipe ( assets . restore ( ) )
@@ -390,7 +419,7 @@ gulp.task('build:client', ['transpile:client', 'styles', 'html'], () => {
390
419
. pipe ( gulp . dest ( paths . dist + '/client' ) ) ;
391
420
} ) ;
392
421
393
- gulp . task ( 'html' , function ( ) {
422
+ gulp . task ( 'html' , function ( ) {
394
423
return gulp . src ( 'client/{app,components}/**/*.html' )
395
424
. pipe ( plugins . angularTemplatecache ( {
396
425
module : '<%= scriptAppName %>'
@@ -404,15 +433,16 @@ gulp.task('jade', function() {
404
433
} ) ; < % } % >
405
434
406
435
gulp . task ( 'constant' , function ( ) {
407
- var config = require ( './server/config/environment/shared' ) ;
436
+ let sharedConfig = require ( './server/config/environment/shared' ) ;
408
437
plugins . ngConstant ( {
409
438
name : '<%= scriptAppName %>.constants' ,
410
439
deps : [ ] ,
411
440
wrap : true ,
412
441
stream : true ,
413
- constants : { appConfig : config } ,
414
- } ) . pipe ( plugins . rename ( {
415
- basename : 'app.constant' ,
442
+ constants : { appConfig : sharedConfig }
443
+ } )
444
+ . pipe ( plugins . rename ( {
445
+ basename : 'app.constant'
416
446
} ) )
417
447
. pipe ( gulp . dest ( 'client/app/' ) )
418
448
} )
0 commit comments