@@ -17,38 +17,39 @@ import nib from 'nib';<% } %>
17
17
var plugins = gulpLoadPlugins ( ) ;
18
18
var config ;
19
19
20
+ const clientPath = require ( './bower.json' ) . appPath || 'client' ;
21
+ const serverPath = 'server' ;
20
22
const paths = {
21
- appPath : require ( './bower.json' ) . appPath || 'client' ,
22
23
client : {
23
- assets : 'client /assets/**/*' ,
24
- images : 'client /assets/images/*' ,
24
+ assets : ` ${ clientPath } /assets/**/*` ,
25
+ images : ` ${ clientPath } /assets/images/**/*` ,
25
26
scripts : [
26
- 'client /**/*.<%= scriptExt %>' ,
27
- '!client /bower_components/**/*.js'
27
+ ` ${ clientPath } /**/*.<%= scriptExt %>` ,
28
+ `! ${ clientPath } /bower_components/**/*.js`
28
29
] ,
29
- styles : [ 'client /{app,components}/**/*.<%= styleExt %>' ] ,
30
- mainStyle : 'client /app/app.<%= styleExt %>' ,
31
- views : 'client /{app,components}/**/*.<%= templateExt %>' ,
32
- mainView : 'client /index.html' ,
33
- test : [ 'client/ **/*.spec.<%= scriptExt %>' ] ,
30
+ styles : [ ` ${ clientPath } /{app,components}/**/*.<%= styleExt %>` ] ,
31
+ mainStyle : ` ${ clientPath } /app/app.<%= styleExt %>` ,
32
+ views : ` ${ clientPath } /{app,components}/**/*.<%= templateExt %>` ,
33
+ mainView : ` ${ clientPath } /index.html` ,
34
+ test : [ ` ${ clientPath } /{app,components}/ **/*.spec.<%= scriptExt %>` ] ,
34
35
testRequire : [
35
- 'client /bower_components/angular/angular.js' ,
36
- 'client /bower_components/angular-mocks/angular-mocks.js' ,
37
- 'client /bower_components/angular-resource/angular-resource.js' ,
38
- 'client /bower_components/angular-cookies/angular-cookies.js' ,
39
- 'client /bower_components/angular-sanitize/angular-sanitize.js' ,
40
- 'client /bower_components/angular-route/angular-route.js' ,
41
- 'client /**/*.spec.<%= scriptExt %>'
36
+ ` ${ clientPath } /bower_components/angular/angular.js` ,
37
+ ` ${ clientPath } /bower_components/angular-mocks/angular-mocks.js` ,
38
+ ` ${ clientPath } /bower_components/angular-resource/angular-resource.js` ,
39
+ ` ${ clientPath } /bower_components/angular-cookies/angular-cookies.js` ,
40
+ ` ${ clientPath } /bower_components/angular-sanitize/angular-sanitize.js` ,
41
+ ` ${ clientPath } /bower_components/angular-route/angular-route.js` ,
42
+ ` ${ clientPath } /**/*.spec.<%= scriptExt %>`
42
43
] ,
43
- bower : 'client /bower_components/'
44
+ bower : ` ${ clientPath } /bower_components/`
44
45
} ,
45
46
server : {
46
- scripts : [ 'server /**/*.<%= scriptExt %>' ] ,
47
- json : [ 'server /**/*.json' ] ,
47
+ scripts : [ ` ${ serverPath } /**/*.<%= scriptExt %>` ] ,
48
+ json : [ ` ${ serverPath } /**/*.json` ] ,
48
49
test : [
49
- 'server /**/*.spec.js' ,
50
- 'server /**/*.mock.js' ,
51
- 'server /**/*.integration.js'
50
+ ` ${ serverPath } /**/*.spec.js` ,
51
+ ` ${ serverPath } /**/*.mock.js` ,
52
+ ` ${ serverPath } /**/*.integration.js`
52
53
]
53
54
} ,
54
55
karma : 'karma.conf.js' ,
@@ -117,13 +118,13 @@ function sortModulesFirst(a, b) {
117
118
let lintClientScripts = lazypipe ( ) < % if ( filters . coffee ) { % >
118
119
. pipe ( plugins . coffeelint )
119
120
. pipe ( plugins . coffeelint . reporter ) ; < % } else { % >
120
- . pipe ( plugins . jshint , 'client /.jshintrc' )
121
+ . pipe ( plugins . jshint , ` ${ clientPath } /.jshintrc` )
121
122
. pipe ( plugins . jshint . reporter , 'jshint-stylish' ) ; < % } % >
122
123
123
124
let lintServerScripts = lazypipe ( ) < % if ( filters . coffee ) { % >
124
125
. pipe ( plugins . coffeelint )
125
126
. pipe ( plugins . coffeelint . reporter ) ; < % } else { % >
126
- . pipe ( plugins . jshint , 'server /.jshintrc' )
127
+ . pipe ( plugins . jshint , ` ${ serverPath } /.jshintrc` )
127
128
. pipe ( plugins . jshint . reporter , 'jshint-stylish' ) ; < % } % >
128
129
129
130
let styles = lazypipe ( )
@@ -152,7 +153,7 @@ let transpile = lazypipe()
152
153
gulp . task ( 'env:all' , ( ) => {
153
154
let localConfig ;
154
155
try {
155
- localConfig = require ( './server /config/local.env' ) ;
156
+ localConfig = require ( `./ ${ serverPath } /config/local.env` ) ;
156
157
} catch ( e ) {
157
158
localConfig = { } ;
158
159
}
@@ -182,31 +183,31 @@ gulp.task('inject', cb => {
182
183
gulp . task ( 'inject:js' , ( ) => {
183
184
return gulp . src ( paths . client . mainView )
184
185
. pipe ( plugins . inject (
185
- gulp . src ( _ . union ( paths . client . scripts , [ '!client /**/*.spec.<%= scriptExt %>' ] ) , { read : false } )
186
+ gulp . src ( _ . union ( paths . client . scripts , [ `! ${ clientPath } /**/*.spec.<%= scriptExt %>` ] ) , { read : false } )
186
187
. pipe ( plugins . sort ( sortModulesFirst ) ) ,
187
188
{
188
189
starttag : '<!-- injector:js -->' ,
189
190
endtag : '<!-- endinjector -->' ,
190
- transform : ( filepath ) => '<script src="' + filepath . replace ( '/client/' , '' ) + '"></script>'
191
+ transform : ( filepath ) => '<script src="' + filepath . replace ( `/ ${ clientPath } /` , '' ) + '"></script>'
191
192
} ) )
192
- . pipe ( gulp . dest ( 'client' ) ) ;
193
+ . pipe ( gulp . dest ( clientPath ) ) ;
193
194
} ) ;
194
195
195
196
gulp . task ( 'inject:css' , ( ) => {
196
197
return gulp . src ( paths . client . mainView )
197
198
. pipe ( plugins . inject (
198
- gulp . src ( '/client /**/*.css' , { read : false } )
199
+ gulp . src ( '/${clientPath}/{app,components} /**/*.css' , { read : false } )
199
200
. pipe ( plugins . sort ( ) ) ,
200
201
{
201
202
starttag : '<!-- injector:css -->' ,
202
203
endtag : '<!-- endinjector -->' ,
203
- transform : ( filepath ) => '<link rel="stylesheet" href="' + filepath . replace ( '/client/' , '' ) . replace ( '/.tmp/' , '' ) + '">'
204
+ transform : ( filepath ) => '<link rel="stylesheet" href="' + filepath . replace ( `/ ${ clientPath } /` , '' ) . replace ( '/.tmp/' , '' ) + '">'
204
205
} ) )
205
- . pipe ( gulp . dest ( 'client' ) ) ;
206
+ . pipe ( gulp . dest ( clientPath ) ) ;
206
207
} ) ;
207
208
208
209
gulp . task ( 'inject:<%= styleExt %>' , ( ) => {
209
- return gulp . src ( ' client/app/app.<%= styleExt %>' )
210
+ return gulp . src ( paths . client . mainStyle )
210
211
. pipe ( plugins . inject (
211
212
gulp . src ( _ . union ( paths . client . styles , [ '!' + paths . client . mainStyle ] ) , { read : false } )
212
213
. pipe ( plugins . sort ( ) ) ,
@@ -215,14 +216,14 @@ gulp.task('inject:<%= styleExt %>', () => {
215
216
endtag : '// endinjector' ,
216
217
transform : ( filepath ) => {
217
218
let newPath = filepath
218
- . replace ( '/client /app/' , '' )
219
- . replace ( '/client /components/' , '../components/' )
219
+ . replace ( `/ ${ clientPath } /app/` , '' )
220
+ . replace ( `/ ${ clientPath } /components/` , '../components/' )
220
221
. replace ( / _ ( .* ) .< % = s t y l e E x t % > / , ( match , p1 , offset , string ) => p1 )
221
222
. replace ( '.<%= styleExt %>' , '' ) ;
222
- return ' @import \'' + newPath + '\';' ;
223
+ return ` @import ' ${ newPath } ';` ;
223
224
}
224
225
} ) )
225
- . pipe ( gulp . dest ( 'client /app' ) ) ;
226
+ . pipe ( gulp . dest ( ` ${ clientPath } /app` ) ) ;
226
227
} ) ;
227
228
228
229
gulp . task ( 'styles' , ( ) => {
@@ -240,7 +241,7 @@ gulp.task('transpile:client', () => {
240
241
gulp . task ( 'transpile:server' , ( ) => {
241
242
return gulp . src ( _ . union ( paths . server . scripts , paths . server . json ) )
242
243
. pipe ( transpile ( ) )
243
- . pipe ( gulp . dest ( paths . dist + '/server' ) ) ;
244
+ . pipe ( gulp . dest ( ` ${ paths . dist } / ${ serverPath } ` ) ) ;
244
245
} ) ;
245
246
246
247
gulp . task ( 'lint:scripts' , cb => runSequence ( [ 'lint:scripts:client' , 'lint:scripts:server' ] , cb ) ) ;
@@ -266,8 +267,8 @@ gulp.task('start:client', cb => {
266
267
267
268
gulp . task ( 'start:server' , ( ) => {
268
269
process . env . NODE_ENV = process . env . NODE_ENV || 'development' ;
269
- config = require ( './server /config/environment' ) ;
270
- nodemon ( ' -w server server' )
270
+ config = require ( `./ ${ serverPath } /config/environment` ) ;
271
+ nodemon ( ` -w ${ serverPath } ${ serverPath } ` )
271
272
. on ( 'log' , onServerLog ) ;
272
273
} ) ;
273
274
@@ -360,9 +361,9 @@ gulp.task('wiredep:client', () => {
360
361
/ b o o t s t r a p .c s s / ,
361
362
/ f o n t - a w e s o m e .c s s /
362
363
] ,
363
- ignorePath : paths . appPath
364
+ ignorePath : clientPath
364
365
} ) )
365
- . pipe ( gulp . dest ( 'client/' ) ) ;
366
+ . pipe ( gulp . dest ( ` ${ clientPath } /` ) ) ;
366
367
} ) ;
367
368
368
369
gulp . task ( 'wiredep:test' , ( ) => {
@@ -402,7 +403,7 @@ gulp.task('build', cb => {
402
403
cb ) ;
403
404
} ) ;
404
405
405
- gulp . task ( 'clean:dist' , ( ) => del ( [ ' dist/**/*' ] ) ) ;
406
+ gulp . task ( 'clean:dist' , ( ) => del ( [ ` ${ paths . dist } /**/*` ] ) ) ;
406
407
407
408
gulp . task ( 'build:client' , [ 'transpile:client' , 'styles' , 'html' ] , ( ) => {
408
409
var appFilter = plugins . filter ( '**/app.js' ) ;
@@ -411,7 +412,7 @@ gulp.task('build:client', ['transpile:client', 'styles', 'html'], () => {
411
412
var htmlFilter = plugins . filter ( '**/*.html' ) ; < % if ( filters . jade ) { % >
412
413
var assetsFilter = plugins . filter ( '**/*.{js,css}' ) ; < % } % >
413
414
414
- let assets = plugins . useref . assets ( { searchPath : [ 'client' , '.tmp' ] } ) ;
415
+ let assets = plugins . useref . assets ( { searchPath : [ clientPath , '.tmp' ] } ) ;
415
416
416
417
return gulp . src ( paths . client . mainView ) < % if ( filters . jade ) { % >
417
418
. pipe ( plugins . jade ( { pretty : true } ) ) < % } % >
@@ -435,11 +436,11 @@ gulp.task('build:client', ['transpile:client', 'styles', 'html'], () => {
435
436
. pipe ( plugins . revReplace ( ) )
436
437
. pipe ( plugins . useref ( ) ) < % if ( filters . jade ) { % >
437
438
. pipe ( assetsFilter ) < % } % >
438
- . pipe ( gulp . dest ( paths . dist + '/client' ) ) ;
439
+ . pipe ( gulp . dest ( ` ${ paths . dist } / ${ clientPath } ` ) ) ;
439
440
} ) ;
440
441
441
442
gulp . task ( 'html' , function ( ) {
442
- return gulp . src ( 'client /{app,components}/**/*.html' )
443
+ return gulp . src ( ` ${ clientPath } /{app,components}/**/*.html` )
443
444
. pipe ( plugins . angularTemplatecache ( {
444
445
module : '<%= scriptAppName %>'
445
446
} ) )
@@ -452,7 +453,7 @@ gulp.task('jade', function() {
452
453
} ) ; < % } % >
453
454
454
455
gulp . task ( 'constant' , function ( ) {
455
- let sharedConfig = require ( './server /config/environment/shared' ) ;
456
+ let sharedConfig = require ( `./ ${ serverPath } /config/environment/shared` ) ;
456
457
plugins . ngConstant ( {
457
458
name : '<%= scriptAppName %>.constants' ,
458
459
deps : [ ] ,
@@ -463,30 +464,30 @@ gulp.task('constant', function() {
463
464
. pipe ( plugins . rename ( {
464
465
basename : 'app.constant'
465
466
} ) )
466
- . pipe ( gulp . dest ( 'client /app/' ) )
467
+ . pipe ( gulp . dest ( ` ${ clientPath } /app/` ) )
467
468
} )
468
469
469
470
gulp . task ( 'build:images' , ( ) => {
470
- return gulp . src ( ' client/assets/ images/**/*' )
471
+ return gulp . src ( paths . client . images )
471
472
. pipe ( plugins . imagemin ( {
472
473
optimizationLevel : 5 ,
473
474
progressive : true ,
474
475
interlaced : true
475
476
} ) )
476
- . pipe ( gulp . dest ( paths . dist + '/client /assets/images' ) ) ;
477
+ . pipe ( gulp . dest ( ` ${ paths . dist } / ${ clientPath } /assets/images` ) ) ;
477
478
} ) ;
478
479
479
480
gulp . task ( 'copy:extras' , ( ) => {
480
481
return gulp . src ( [
481
- 'client /favicon.ico' ,
482
- 'client /robots.txt'
482
+ ` ${ clientPath } /favicon.ico` ,
483
+ ` ${ clientPath } /robots.txt`
483
484
] , { dot : true } )
484
- . pipe ( gulp . dest ( paths . dist + '/client' ) ) ;
485
+ . pipe ( gulp . dest ( ` ${ paths . dist } / ${ clientPath } ` ) ) ;
485
486
} ) ;
486
487
487
488
gulp . task ( 'copy:assets' , ( ) => {
488
489
return gulp . src ( [ paths . client . assets , '!' + paths . client . images ] )
489
- . pipe ( gulp . dest ( paths . dist + '/client /assets' ) ) ;
490
+ . pipe ( gulp . dest ( ` ${ paths . dist } / ${ clientPath } /assets` ) ) ;
490
491
} ) ;
491
492
492
493
gulp . task ( 'copy:server' , ( ) => {
0 commit comments