Skip to content

Commit 05ee5c9

Browse files
committed
feat(gulp:inject): use gulp-sort for injectors
1 parent 2ce94c9 commit 05ee5c9

1 file changed

Lines changed: 30 additions & 24 deletions

File tree

app/templates/gulpfile.babel(gulp).js

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -133,40 +133,46 @@ gulp.task('inject', cb => {
133133

134134
gulp.task('inject:js', () => {
135135
return gulp.src(paths.mainView)
136-
.pipe(plugins.inject(gulp.src(_.union(
137-
paths.client.scripts,
138-
['!client/**/*.spec.<%= scriptExt %>']
139-
), {read: false}), {
140-
starttag: '<!-- injector:js -->',
141-
endtag: '<!-- endinjector -->',
142-
transform: (filepath) => '<script src="' + filepath.replace('/client/', '') + '"></script>'
143-
}))
136+
.pipe(plugins.inject(
137+
gulp.src(_.union(paths.client.scripts, ['!client/**/*.spec.<%= scriptExt %>']), {read: false})
138+
.pipe(plugins.sort())
139+
, {
140+
starttag: '<!-- injector:js -->',
141+
endtag: '<!-- endinjector -->',
142+
transform: (filepath) => '<script src="' + filepath.replace('/client/', '') + '"></script>'
143+
}))
144144
.pipe(gulp.dest('client'));
145145
});
146146

147147
gulp.task('inject:css', () => {
148148
return gulp.src(paths.mainView)
149-
.pipe(plugins.inject(gulp.src('/client/**/*.css', {read: false}), {
150-
starttag: '<!-- injector:css -->',
151-
endtag: '<!-- endinjector -->',
152-
transform: (filepath) => '<link rel="stylesheet" href="' + filepath.replace('/client/', '').replace('/.tmp/', '') + '">'
153-
}))
149+
.pipe(plugins.inject(
150+
gulp.src('/client/**/*.css', {read: false})
151+
.pipe(plugins.sort())
152+
, {
153+
starttag: '<!-- injector:css -->',
154+
endtag: '<!-- endinjector -->',
155+
transform: (filepath) => '<link rel="stylesheet" href="' + filepath.replace('/client/', '').replace('/.tmp/', '') + '">'
156+
}))
154157
.pipe(gulp.dest('client'));
155158
});
156159

157160
gulp.task('inject:<%= styleExt %>', () => {
158161
return gulp.src('client/app/app.<%= styleExt %>')
159-
.pipe(plugins.inject(gulp.src(_.union(paths.client.styles, ['!' + paths.client.mainStyle]), {read: false}), {
160-
starttag: '// injector',
161-
endtag: '// endinjector',
162-
transform: (filepath) => {
163-
let newPath = filepath
164-
.replace('/client/app/', '')
165-
.replace('/client/components/', '../components/')
166-
.replace(/_(.*).<%= styleExt %>/, (match, p1, offset, string) => p1);
167-
return '@import \'' + newPath + '\';';
168-
}
169-
}))
162+
.pipe(plugins.inject(
163+
gulp.src(_.union(paths.client.styles, ['!' + paths.client.mainStyle]), {read: false})
164+
.pipe(plugins.sort())
165+
, {
166+
starttag: '// injector',
167+
endtag: '// endinjector',
168+
transform: (filepath) => {
169+
let newPath = filepath
170+
.replace('/client/app/', '')
171+
.replace('/client/components/', '../components/')
172+
.replace(/_(.*).<%= styleExt %>/, (match, p1, offset, string) => p1);
173+
return '@import \'' + newPath + '\';';
174+
}
175+
}))
170176
.pipe(gulp.dest('client/app'));
171177
});
172178

0 commit comments

Comments
 (0)