File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,25 @@ function whenServerReady(cb) {
9191 100 ) ;
9292}
9393
94+ function sortModulesFirst ( a , b ) {
95+ var module = / \. m o d u l e \. j s $ / ;
96+ var aMod = module . test ( a . path ) ;
97+ var bMod = module . test ( b . path ) ;
98+ // inject *.module.js first
99+ if ( aMod === bMod ) {
100+ // either both modules or both non-modules, so just sort normally
101+ if ( a . path < b . path ) {
102+ return - 1 ;
103+ }
104+ if ( a . path > b . path ) {
105+ return 1 ;
106+ }
107+ return 0 ;
108+ } else {
109+ return ( aMod ? - 1 : 1 ) ;
110+ }
111+ }
112+
94113/********************
95114 * Reusable pipelines
96115 ********************/
@@ -164,7 +183,7 @@ gulp.task('inject:js', () => {
164183 return gulp . src ( paths . client . mainView )
165184 . pipe ( plugins . inject (
166185 gulp . src ( _ . union ( paths . client . scripts , [ '!client/**/*.spec.<%= scriptExt %>' ] ) , { read : false } )
167- . pipe ( plugins . sort ( ) ) ,
186+ . pipe ( plugins . sort ( sortModulesFirst ) ) ,
168187 {
169188 starttag : '<!-- injector:js -->' ,
170189 endtag : '<!-- endinjector -->' ,
You can’t perform that action at this time.
0 commit comments