Reputation: 3101
I am using runsequence plugin. But It seems that I am doing something wrong so it is not working. I am trying to create browserify build and concat it with my handlebars precompiled templates on server using run-sequence gulp plugin.
In gulpfile correspoding tasks looks like this:
gulp.task("browserify", function () {
gulp.src('src/js/map.js')
.pipe(browserify({
insertGlobals: false,
debug: false
}))
.pipe(gulp.dest('build'))
.pipe(notify({ message: "browserify ended" }));
});
gulp.task("scripts", function () {
var newDir;
newDir = './build/1111';
gulp.src(['./build/map.js', './build/templates/templates.js'])
.pipe(concat('build.js'))
.pipe(gulp.dest(newDir))
.pipe(notify({ message: "scripts build ended" }));
});
gulp.task('default', function () {
runSequence( 'browserify', 'scripts' );
});
But actually scripts task are trying invoke before browserify task is done. So I get this output:
$ gulp
[10:40:26] Using gulpfile ~/projects/map2/gulpfile.js
[10:40:26] Starting 'default'...
[10:40:26] Starting 'browserify'...
[10:40:26] Finished 'browserify' after 7.84 ms
[10:40:26] Starting 'scripts'...
[10:40:26] Finished 'scripts' after 4.58 ms
[10:40:26] Finished 'default' after 14 ms
[10:40:26] gulp-notify: [Gulp notification] templates build ended
[10:40:26] gulp-notify: [Gulp notification] browserify ended
And scripts
task don't create build.js file (note there is no message "scripts build ended" from notify plugin).
Upvotes: 1
Views: 290
Reputation: 52888
Similar to the answer you added, but a little cleaner in my opinion, is to remove return stream
and replace var stream =
with return
.
gulp.task('browserify', function (cb) {
return gulp.src('src/js/clientAppControl.js')
.pipe(browserify({
insertGlobals: false,
debug: false
}))
.pipe(gulp.dest('build'))
.pipe(notify({ message: 'browserify ended' }));
});
Upvotes: 1
Reputation: 3101
I figured out it myself. For achieving this there should be some signal from task about finishing work. Check this article for more information. Actually I choose to return stream like this:
gulp.task('browserify', function (cb) {
var stream = gulp.src('src/js/clientAppControl.js')
.pipe(browserify({
insertGlobals: false,
debug: false
}))
.pipe(gulp.dest('build'))
.pipe(notify({ message: 'browserify ended' }));
return stream;
});
and dependencies started to work properly.
Upvotes: 1