@@ -68,7 +68,7 @@ function onServerLog(log) {
6868function checkAppReady ( cb ) {
6969 var options = {
7070 host : 'localhost' ,
71- port : config . port ,
71+ port : config . port
7272 } ;
7373 http
7474 . get ( options , ( ) => cb ( true ) )
@@ -80,7 +80,7 @@ function whenServerReady(cb) {
8080 var serverReady = false ;
8181 var appReadyInterval = setInterval ( ( ) =>
8282 checkAppReady ( ( ready ) => {
83- if ( ! ready || serverReady ) {
83+ if ( ! ready || serverReady ) {
8484 return ;
8585 }
8686 clearInterval ( appReadyInterval ) ;
@@ -123,6 +123,32 @@ let transpile = lazypipe()
123123 . pipe ( plugins . coffee , { bare : true } ) < % } % >
124124 . pipe ( plugins . sourcemaps . write , '.' ) ; < % } % >
125125
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+
126152/********************
127153 * Tasks
128154 ********************/
@@ -135,8 +161,8 @@ gulp.task('inject:js', () => {
135161 return gulp . src ( paths . client . mainView )
136162 . pipe ( plugins . inject (
137163 gulp . src ( _ . union ( paths . client . scripts , [ '!client/**/*.spec.<%= scriptExt %>' ] ) , { read : false } )
138- . pipe ( plugins . sort ( ) )
139- , {
164+ . pipe ( plugins . sort ( ) ) ,
165+ {
140166 starttag : '<!-- injector:js -->' ,
141167 endtag : '<!-- endinjector -->' ,
142168 transform : ( filepath ) => '<script src="' + filepath . replace ( '/client/' , '' ) + '"></script>'
@@ -148,8 +174,8 @@ gulp.task('inject:css', () => {
148174 return gulp . src ( paths . client . mainView )
149175 . pipe ( plugins . inject (
150176 gulp . src ( '/client/**/*.css' , { read : false } )
151- . pipe ( plugins . sort ( ) )
152- , {
177+ . pipe ( plugins . sort ( ) ) ,
178+ {
153179 starttag : '<!-- injector:css -->' ,
154180 endtag : '<!-- endinjector -->' ,
155181 transform : ( filepath ) => '<link rel="stylesheet" href="' + filepath . replace ( '/client/' , '' ) . replace ( '/.tmp/' , '' ) + '">'
@@ -161,8 +187,8 @@ gulp.task('inject:<%= styleExt %>', () => {
161187 return gulp . src ( 'client/app/app.<%= styleExt %>' )
162188 . pipe ( plugins . inject (
163189 gulp . src ( _ . union ( paths . client . styles , [ '!' + paths . client . mainStyle ] ) , { read : false } )
164- . pipe ( plugins . sort ( ) )
165- , {
190+ . pipe ( plugins . sort ( ) ) ,
191+ {
166192 starttag : '// injector' ,
167193 endtag : '// endinjector' ,
168194 transform : ( filepath ) => {
@@ -289,7 +315,7 @@ gulp.task('mocha:unit', () => {
289315 './mocha.conf'
290316 ]
291317 } ) )
292- . once ( 'end' , function ( ) {
318+ . once ( 'end' , function ( ) {
293319 process . exit ( ) ;
294320 } ) ;
295321} ) ;
@@ -380,7 +406,10 @@ gulp.task('build:client', ['transpile:client', 'styles', 'html'], () => {
380406 . pipe ( plugins . uglify ( ) )
381407 . pipe ( jsFilter . restore ( ) )
382408 . 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+ } ) )
384413 . pipe ( cssFilter . restore ( ) )
385414 . pipe ( plugins . rev ( ) )
386415 . pipe ( assets . restore ( ) )
@@ -390,7 +419,7 @@ gulp.task('build:client', ['transpile:client', 'styles', 'html'], () => {
390419 . pipe ( gulp . dest ( paths . dist + '/client' ) ) ;
391420} ) ;
392421
393- gulp . task ( 'html' , function ( ) {
422+ gulp . task ( 'html' , function ( ) {
394423 return gulp . src ( 'client/{app,components}/**/*.html' )
395424 . pipe ( plugins . angularTemplatecache ( {
396425 module : '<%= scriptAppName %>'
@@ -404,15 +433,16 @@ gulp.task('jade', function() {
404433} ) ; < % } % >
405434
406435gulp . task ( 'constant' , function ( ) {
407- var config = require ( './server/config/environment/shared' ) ;
436+ let sharedConfig = require ( './server/config/environment/shared' ) ;
408437 plugins . ngConstant ( {
409438 name : '<%= scriptAppName %>.constants' ,
410439 deps : [ ] ,
411440 wrap : true ,
412441 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'
416446 } ) )
417447 . pipe ( gulp . dest ( 'client/app/' ) )
418448} )
0 commit comments