@@ -17,7 +17,8 @@ module.exports = function (grunt) {
1717 cdnify : 'grunt-google-cdn' ,
1818 protractor : 'grunt-protractor-runner' ,
1919 buildcontrol : 'grunt-build-control' ,
20- istanbul_check_coverage : 'grunt-mocha-istanbul'
20+ istanbul_check_coverage : 'grunt-mocha-istanbul' ,
21+ ngconstant : 'grunt-ng-constant'
2122 } ) ;
2223
2324 // Time how long tasks take. Can help when optimizing build times
@@ -60,6 +61,10 @@ module.exports = function (grunt) {
6061 files : [ '<%%= yeoman.client %>/{app,components}/**/!(*.spec|*.mock).js' ] ,
6162 tasks : [ 'newer:babel:client' ]
6263 } , < % } % >
64+ ngconstant : {
65+ files : [ '<%%= yeoman.server %>/config/environment/shared.js' ] ,
66+ tasks : [ 'ngconstant' ]
67+ } ,
6368 injectJS : {
6469 files : [
6570 '<%%= yeoman.client %>/{app,components}/**/!(*.spec|*.mock).js' ,
@@ -241,7 +246,7 @@ module.exports = function (grunt) {
241246 // Automatically inject Bower components into the app and karma.conf.js
242247 wiredep: {
243248 options : {
244- exclude : [ < % if ( filters . uibootstrap ) { % >
249+ exclude : [ < % if ( filters . uibootstrap ) { % >
245250 / b o o t s t r a p .j s / , < % } % >
246251 '/json3/',
247252 '/es5-shim/'< % if ( ! filters . css ) { % > ,
@@ -326,6 +331,25 @@ module.exports = function (grunt) {
326331 }
327332 } ,
328333
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+
329353 // Package all the html partials into a single javascript payload
330354 ngtemplates: {
331355 options : {
@@ -423,6 +447,12 @@ module.exports = function (grunt) {
423447
424448 // Run some tasks in parallel to speed up the build process
425449 concurrent: {
450+ pre : [ < % if ( filters . stylus ) { % >
451+ 'injector:stylus' , < % } if (filters.less) { % >
452+ 'injector:less' , < % } if (filters.sass) { % >
453+ 'injector:sass' , < % } %>
454+ 'ngconstant '
455+ ] ,
426456 server : [ < % if ( filters . babel ) { % >
427457 'newer:babel:client',< % } if ( filters . jade ) { % >
428458 'jade',< % } if ( filters . stylus ) { % >
@@ -747,10 +777,8 @@ module.exports = function (grunt) {
747777 if (target === 'debug') {
748778 return grunt . task . run ( [
749779 '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' ,
754782 'concurrent:server' ,
755783 'injector' ,
756784 'wiredep:client' ,
@@ -761,10 +789,8 @@ module.exports = function (grunt) {
761789
762790 grunt.task.run([
763791 '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',
768794 'concurrent:server',
769795 'injector',
770796 'wiredep:client',
@@ -794,10 +820,8 @@ module.exports = function (grunt) {
794820 else if (target === 'client') {
795821 return grunt . task . run ( [
796822 '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' ,
801825 'concurrent:test' ,
802826 'injector' ,
803827 'postcss' ,
@@ -822,10 +846,8 @@ module.exports = function (grunt) {
822846 return grunt . task . run ( [
823847 'clean:server' ,
824848 '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' ,
829851 'concurrent:test' ,
830852 'injector' ,
831853 'wiredep:client' ,
@@ -878,10 +900,8 @@ module.exports = function (grunt) {
878900 } ) ;
879901
880902 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 ',
885905 'concurrent :dist ',
886906 'injector ',
887907 'wiredep :client ',
0 commit comments