Данная проблема реширась вот так:
gulpfile.js
var gulp = require('gulp');
var resolveDependencies = require('gulp-resolve-dependencies');
var concat = require('gulp-concat');
var del = require('del');
var order = require('gulp-order');
// JS tasks
// ==========================
// merge files from 2 directories and put them to tmp folder
gulp.task('js:merge', function (cb) {
var stream = gulp
.src(['./base/js/**/**', './js/**/**'])
.pipe(gulp.dest('./merged-js'))
;
stream.on('end', function () {
cb();
});
});
// resolve dependencies and build concatenated version
gulp.task('js:concat', ['js:merge'], function (cb) {
var stream = gulp
.src(['./merged-js/**/**'])
.pipe(order([
'constants.js',
'config-base.js',
'config.js',
'app.js',
'utils/*',
'services/*',
'controllers/**/**',
'ui/*',
'views/**/**',
'bootstrap.js'
]))
.pipe(resolveDependencies({
resolvePath: function (match, targetFile) {
return './merged-js/' + match;
}
}))
.pipe(concat('build.js'))
.pipe(gulp.dest('./'))
;
stream.on('end', function () {
cb();
});
});
// delete tmp folder
gulp.task('js:cleanup', ['js:concat'], function () {
del('./merged-js');
});
// ==========================
// HTML tasks
// ==========================
gulp.task('html:merge', function (cb) {
var stream = gulp
.src(['./base/views/**/**', './views/**/**'])
.pipe(gulp.dest('./merged-html'))
;
stream.on('end', function () {
cb();
});
});
gulp.task('html:concat', ['html:merge'], function (cb) {
var stream = gulp
.src(['./merged-html/**/**'])
.pipe(order([
'index.start.html',
'body.html',
'templates/**/**',
'index.end.html'
]))
.pipe(concat('index.html'))
.pipe(gulp.dest('./'))
;
stream.on('end', function () {
cb();
});
});
// delete tmp folder
gulp.task('html:cleanup', ['html:concat'], function () {
del('./merged-html');
});
// ==========================
// Default Task
gulp.task('default', [
'js:merge', 'js:concat', 'js:cleanup',
'html:merge', 'html:concat', 'html:cleanup'
]);