@@ -17,7 +17,8 @@ module.exports = function (grunt) {
17
17
cdnify : 'grunt-google-cdn' ,
18
18
protractor : 'grunt-protractor-runner' ,
19
19
buildcontrol : 'grunt-build-control' ,
20
- istanbul_check_coverage : 'grunt-mocha-istanbul'
20
+ istanbul_check_coverage : 'grunt-mocha-istanbul' ,
21
+ ngconstant : 'grunt-ng-constant'
21
22
} ) ;
22
23
23
24
// Time how long tasks take. Can help when optimizing build times
@@ -60,6 +61,10 @@ module.exports = function (grunt) {
60
61
files : [ '<%%= yeoman.client %>/{app,components}/**/!(*.spec|*.mock).js' ] ,
61
62
tasks : [ 'newer:babel:client' ]
62
63
} , < % } % >
64
+ ngconstant : {
65
+ files : [ '<%%= yeoman.server %>/config/environment/shared.js' ] ,
66
+ tasks : [ 'ngconstant' ]
67
+ } ,
63
68
injectJS : {
64
69
files : [
65
70
'<%%= yeoman.client %>/{app,components}/**/!(*.spec|*.mock).js' ,
@@ -241,7 +246,7 @@ module.exports = function (grunt) {
241
246
// Automatically inject Bower components into the app and karma.conf.js
242
247
wiredep: {
243
248
options : {
244
- exclude : [ < % if ( filters . uibootstrap ) { % >
249
+ exclude : [ < % if ( filters . uibootstrap ) { % >
245
250
/ b o o t s t r a p .j s / , < % } % >
246
251
'/json3/',
247
252
'/es5-shim/'< % if ( ! filters . css ) { % > ,
@@ -326,6 +331,25 @@ module.exports = function (grunt) {
326
331
}
327
332
} ,
328
333
334
+ // Dynamically generate angular constant `appConfig` from
335
+ // `server/config/environment/shared.js`
336
+ ngconstant: {
337
+ options : {
338
+ name : '<%= scriptAppName %>.constants' ,
339
+ dest : '<%%= yeoman.client %>/app/app.constant.js' ,
340
+ deps : [ ] ,
341
+ wrap : true ,
342
+ configPath : '<%%= yeoman.server %>/config/environment/shared'
343
+ } ,
344
+ app : {
345
+ constants : function ( ) {
346
+ return {
347
+ appConfig : require ( './' + grunt . config . get ( 'ngconstant.options.configPath' ) )
348
+ } ;
349
+ }
350
+ }
351
+ } ,
352
+
329
353
// Package all the html partials into a single javascript payload
330
354
ngtemplates: {
331
355
options : {
@@ -423,6 +447,12 @@ module.exports = function (grunt) {
423
447
424
448
// Run some tasks in parallel to speed up the build process
425
449
concurrent: {
450
+ pre : [ < % if ( filters . stylus ) { % >
451
+ 'injector:stylus' , < % } if (filters.less) { % >
452
+ 'injector:less' , < % } if (filters.sass) { % >
453
+ 'injector:sass' , < % } %>
454
+ 'ngconstant '
455
+ ] ,
426
456
server : [ < % if ( filters . babel ) { % >
427
457
'newer:babel:client',< % } if ( filters . jade ) { % >
428
458
'jade',< % } if ( filters . stylus ) { % >
@@ -747,10 +777,8 @@ module.exports = function (grunt) {
747
777
if (target === 'debug') {
748
778
return grunt . task . run ( [
749
779
'clean:server' ,
750
- 'env:all' , < % if ( filters . stylus ) { % >
751
- 'injector:stylus' , < % } if (filters.less) { % >
752
- 'injector:less' , < % } if (filters.sass) { % >
753
- 'injector:sass' , < % } %>
780
+ 'env:all' ,
781
+ 'concurrent:pre' ,
754
782
'concurrent:server' ,
755
783
'injector' ,
756
784
'wiredep:client' ,
@@ -761,10 +789,8 @@ module.exports = function (grunt) {
761
789
762
790
grunt.task.run([
763
791
'clean:server',
764
- 'env :all ', < % if ( filters . stylus ) { % >
765
- 'injector:stylus',< % } if ( filters . less ) { % >
766
- 'injector:less',< % } if ( filters . sass ) { % >
767
- 'injector:sass',< % } % >
792
+ 'env:all',
793
+ 'concurrent:pre',
768
794
'concurrent:server',
769
795
'injector',
770
796
'wiredep:client',
@@ -794,10 +820,8 @@ module.exports = function (grunt) {
794
820
else if (target === 'client') {
795
821
return grunt . task . run ( [
796
822
'clean:server' ,
797
- 'env:all' , < % if ( filters . stylus ) { % >
798
- 'injector:stylus' , < % } if (filters.less) { % >
799
- 'injector:less' , < % } if (filters.sass) { % >
800
- 'injector:sass' , < % } %>
823
+ 'env:all' ,
824
+ 'concurrent:pre' ,
801
825
'concurrent:test' ,
802
826
'injector' ,
803
827
'postcss' ,
@@ -822,10 +846,8 @@ module.exports = function (grunt) {
822
846
return grunt . task . run ( [
823
847
'clean:server' ,
824
848
'env:all' ,
825
- 'env:test' , < % if ( filters . stylus ) { % >
826
- 'injector:stylus' , < % } if (filters.less) { % >
827
- 'injector:less' , < % } if (filters.sass) { % >
828
- 'injector:sass' , < % } %>
849
+ 'env:test' ,
850
+ 'concurrent:pre' ,
829
851
'concurrent:test' ,
830
852
'injector' ,
831
853
'wiredep:client' ,
@@ -878,10 +900,8 @@ module.exports = function (grunt) {
878
900
} ) ;
879
901
880
902
grunt . registerTask ( 'build ', [
881
- 'clean :dist ', < % if ( filters . stylus ) { % >
882
- 'injector:stylus',< % } if ( filters . less ) { % >
883
- 'injector:less',< % } if ( filters . sass ) { % >
884
- 'injector:sass',< % } % >
903
+ 'clean :dist ',
904
+ 'concurrent :pre ',
885
905
'concurrent :dist ',
886
906
'injector ',
887
907
'wiredep :client ',
0 commit comments